{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "config",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✓ 配置信息已设置\n"
     ]
    }
   ],
   "source": [
    "# 配置信息\n",
    "POSTGRES_USER = \"docker\"\n",
    "POSTGRES_PASSWORD = \"docker\"\n",
    "POSTGRES_HOST = \"localhost\"\n",
    "POSTGRES_PORT = \"5432\"\n",
    "POSTGRES_DB = \"streamlit_generic\"\n",
    "VECTOR_SIZE = 1024\n",
    "\n",
    "print(\"✓ 配置信息已设置\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "connection",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✓ 连接字符串: postgresql+asyncpg://docker:docker@localhost:5432/streamlit_generic\n"
     ]
    }
   ],
   "source": [
    "# 数据库连接字符串\n",
    "CONNECTION_STRING = (\n",
    "    f\"postgresql+asyncpg://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}\"\n",
    "    f\":{POSTGRES_PORT}/{POSTGRES_DB}\"\n",
    ")\n",
    "print(f\"✓ 连接字符串: {CONNECTION_STRING}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "engine",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✓ PostgreSQL 引擎初始化完成\n"
     ]
    }
   ],
   "source": [
    "# 初始化 PostgreSQL 引擎\n",
    "from langchain_postgres import PGEngine\n",
    "\n",
    "pg_engine = PGEngine.from_connection_string(url=CONNECTION_STRING)\n",
    "print(\"✓ PostgreSQL 引擎初始化完成\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "fe5f22d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.09829633682966232, 0.03433719649910927, -0.06495697796344757, -0.023008856922388077, -0.041752465069293976, -0.04022636637091637, 0.037056781351566315, 0.10463551431894302, -0.03048282116651535, 0.004734815564006567, 0.0029763795901089907, 0.01569141447544098, 0.009225064888596535, -0.013324006460607052, 0.014615319669246674, -0.012423999607563019, 0.04151768237352371, -0.010007678531110287, -0.03279153257608414, -0.0565047413110733, -0.0707874521613121, -0.015251193195581436, 0.04875686392188072, 0.04437422379851341, 0.011592471972107887, 0.09430500864982605, -0.04386552423238754, -0.026941493153572083, 0.039404623210430145, -0.040108975023031235, 0.06120042875409126, -0.032165441662073135, 0.04820903390645981, -0.055017776787281036, -0.009381587617099285, -0.01228704210370779, 0.00012358272215351462, -0.01955557055771351, -0.11042685806751251, -0.0007110783481039107, 0.05431342124938965, -0.029993688687682152, 0.008775060996413231, -0.04680032655596733, 0.0011237850412726402, -0.03281109780073166, 0.01680663973093033, -0.06836134940385818, -0.02782193385064602, -0.014703363180160522, -0.0268240999430418, 0.005038078874349594, 0.03376980125904083, -0.02966107614338398, 0.021130582317709923, -0.016239244490861893, 0.0028100740164518356, -0.022578418254852295, -0.05634821951389313, 0.021737108007073402, -0.06836134940385818, 0.008065816946327686, -0.010222897864878178, 0.01650337688624859, 0.02926976978778839, 0.07900489866733551, 0.03545242175459862, 0.00024013414804358035, -0.0495394766330719, -0.049382954835891724, -0.038993749767541885, -0.007630487903952599, -0.011201165616512299, 0.01136747095733881, -0.07579617947340012, 0.008197883144021034, 0.007244072388857603, -0.01989796571433544, 0.017667515203356743, -0.02987629547715187, 0.08671364933252335, 0.028506720438599586, 0.021267540752887726, 0.010418551042675972, -0.008422885090112686, -0.0003405594325158745, -0.009078324772417545, 0.001033295295201242, -0.0038054613396525383, -0.003394588828086853, -0.07466138899326324, -0.04883512482047081, 0.03691982477903366, -0.0324002280831337, -0.051848188042640686, 0.020308837294578552, -0.037252433598041534, 0.03200891986489296, 0.012688132002949715, 0.02529800310730934, 0.022461026906967163, 0.03488502651453018, 0.005737540312111378, -0.045313358306884766, 0.047348156571388245, -0.030130645260214806, 0.02917194366455078, 0.024084951728582382, 0.025845833122730255, -0.02467191219329834, 0.023889297619462013, 0.019594702869653702, 0.03993288800120354, 0.010350072756409645, 0.00799733866006136, 0.019604485481977463, -0.01996644400060177, -0.021737108007073402, -0.03326110169291496, 0.012531609274446964, 0.029719773679971695, -0.01988818310201168, 0.043787263333797455, -0.05830475687980652, 0.010389203205704689, -0.04523509740829468, 0.02946542389690876, 0.037585046142339706, 0.01621967926621437, -0.03719373792409897, 0.02662844769656658, 0.0466829352080822, 0.006652220617979765, -0.025356698781251907, -0.07297877222299576, -0.03357414901256561, 0.019721876829862595, 0.01071203127503395, 0.00912234652787447, -0.044491615146398544, 0.06390044838190079, -0.016043590381741524, -0.019809920340776443, 0.00020864616089966148, 0.022265372797846794, -0.05646561086177826, 0.026452358812093735, 0.001825692132115364, 0.02568930946290493, 0.016239244490861893, -0.020250141620635986, 0.0002320328785572201, 0.018322953954339027, -0.012854437343776226, 0.04515683650970459, 0.003932636231184006, 0.007992447353899479, 0.006143521051853895, 0.052669934928417206, 0.08209622651338577, -0.0007080212235450745, -0.002339282538741827, -0.020856667309999466, -0.007914185523986816, -0.030032819136977196, 0.05098731443285942, 0.013754444196820259, 0.03592199087142944, -0.031148044392466545, -0.03815244138240814, 0.00767451012507081, -0.020025139674544334, 0.008403319865465164, -0.015574022196233273, 0.021287105977535248, 0.040617674589157104, 0.09774851053953171, 0.010985946282744408, 0.017462078481912613, -0.05716996639966965, -0.0352567695081234, 0.05423516035079956, -0.03208718076348305, -0.020426230505108833, -0.01653272472321987, -0.0014453905168920755, 0.005238623358309269, 0.00794842466711998, -0.0015297661302611232, 0.002998390467837453, -0.0336524099111557, -0.05345254763960838, 0.005419603083282709, -0.03707634657621384, -0.0031475762370973825, 0.016239244490861893, 0.016855552792549133, -0.015759892761707306, 0.0005707580712623894, -0.029621945694088936, -0.05658300593495369, 0.002956814132630825, 0.03805461525917053, 0.006495697423815727, -0.0035804598592221737, -0.022265372797846794, -0.06073085963726044, -0.03564807400107384, 0.01639576628804207, -0.06675698608160019, -0.04586118832230568, 0.016160981729626656, -0.019222959876060486, -0.01116203423589468, -0.007796793710440397, -0.016180546954274178, 0.018675129860639572, -0.01054572593420744, 0.025141479447484016, -0.03993288800120354, -0.02118927799165249, 0.028467589989304543, 0.040617674589157104, 0.04488292336463928, 0.02426103875041008, -1.541918027214706e-05, 0.021678412333130836, 0.055291689932346344, 0.04108724370598793, -0.037369824945926666, -0.018117517232894897, -0.00558101711794734, 0.018283823505043983, -0.024221908301115036, 0.059596069157123566, 0.00048332539154216647, -0.004243236035108566, 0.004600303713232279, 0.029798034578561783, -0.004959817044436932, 0.007141354028135538, -0.008652777411043644, 0.033808931708335876, -0.00718537624925375, -0.04578292742371559, -0.02060231752693653, 0.03026760369539261, 0.006383196916431189, -0.017872951924800873, -0.0032062723767012358, 0.0023490653838962317, -0.020132750272750854, -0.01519249752163887, 0.04005027934908867, -0.009342456236481667, 0.020054487511515617, 0.023595817387104034, -0.025532787665724754, 0.02496539242565632, -0.0422220341861248, 0.004023125860840082, -0.015290324576199055, 0.033476319164037704, 0.04089159145951271, -0.005414711777120829, -0.03813287615776062, -0.053569938987493515, 0.009083216078579426, 0.008129404857754707, -0.015613152645528316, 0.001549331471323967, -0.04496118426322937, 0.01105442550033331, -0.013685964979231358, 0.002550833160057664, -0.007082658354192972, -0.03701765090227127, -0.00851582083851099, 0.02803715318441391, 0.020034922286868095, -0.017060989513993263, 0.0015028637135401368, 0.016855552792549133, -0.02040666528046131, 0.0020372425206005573, -0.03915027529001236, 0.0065495022572577, -0.031363263726234436, 0.0179414302110672, 0.001352455117739737, 0.0009201830835081637, 0.009675067849457264, 0.05493951588869095, -0.00861853826791048, -0.027293669059872627, -0.006114173214882612, 0.02516104467213154, -0.18892306089401245, -0.005248406436294317, 0.0015566684305667877, -0.010144636034965515, 0.02109145186841488, 0.009631045162677765, -0.010213115252554417, -0.04515683650970459, 0.007767445407807827, 0.05372646078467369, 0.016444679349660873, -0.04496118426322937, -0.060809120535850525, 0.002770943334326148, -0.02026970684528351, 0.0023564023431390524, -0.010222897864878178, -0.03351545333862305, -0.003208718029782176, -0.02314581349492073, -0.019712094217538834, -0.025121914222836494, 0.0978267714381218, 0.021228408440947533, 0.012013127095997334, -0.0051750363782048225, 0.0670309066772461, -0.028115414083003998, -0.023087117820978165, 0.007239181082695723, 0.00860875565558672, -0.022695811465382576, -0.013999010436236858, 0.045509014278650284, 0.009053867310285568, 0.05654387176036835, 0.05059600621461868, 0.004602749366313219, -0.04085246101021767, -0.02447625808417797, 0.006143521051853895, 0.030521951615810394, -0.016552289947867393, 0.014204447157680988, 0.019418613985180855, -0.009234847500920296, 0.055526476353406906, -0.013187048956751823, -0.04421770200133324, -0.03596112132072449, -0.01622946187853813, 0.0009097889414988458, 0.008877779357135296, -0.028056718409061432, -0.03979593142867088, -0.022656679153442383, -0.025924094021320343, 0.035511117428541183, -0.042339425534009933, 0.002704910235479474, 0.007513096090406179, -0.041126374155282974, 0.05043948441743851, 0.011934866197407246, -0.001868491293862462, -0.01958492025732994, 0.013656617142260075, -0.020837102085351944, -0.013999010436236858, -0.01704142428934574, 0.013666399754583836, 0.01793164759874344, 0.006466349586844444, -0.023106683045625687, 0.017305554822087288, 0.019428396597504616, 0.009479413740336895, -0.010614204220473766, -0.012120736762881279, -0.08921801298856735, 0.02995455637574196, 0.029132813215255737, -0.023713208734989166, 0.003961984068155289, -0.01997622661292553, -0.015055540017783642, -0.015652284026145935, 0.006290261168032885, 0.02813497930765152, 0.26514968276023865, -0.004649217240512371, 0.0007000728510320187, -0.03353501856327057, 0.030306734144687653, -0.022187111899256706, -0.04852207750082016, -0.030541518703103065, -0.036137208342552185, -0.04273073375225067, 0.018225127831101418, -0.01600445993244648, -0.006280478555709124, 0.025728439912199974, 0.018195779994130135, 0.029191508889198303, -0.010173983871936798, -0.011964214034378529, 0.09109628945589066, -0.004199214279651642, 0.03932636231184006, -0.013480529189109802, 0.03641112521290779, 0.009973439387977123, -0.03652851656079292, -0.02641322836279869, 0.0034459480084478855, -0.0009293543407693505, -0.05513516813516617, 0.02336103282868862, -0.021071886643767357, -0.008872888050973415, 0.03255674988031387, 0.001682620495557785, 0.022480592131614685, 0.013187048956751823, 0.03958071023225784, -0.016650116071105003, -0.021580586209893227, 0.014693580567836761, -0.010985946282744408, -0.031852398067712784, -0.02670670859515667, 0.03353501856327057, -0.013979445211589336, -0.011807691305875778, -0.007327225059270859, -0.03568720445036888, 0.019907748326659203, -0.03148065507411957, 0.02692192792892456, 0.011582689359784126, 0.01578924059867859, 0.03484589606523514, 0.008290818892419338, 0.041830725967884064, -0.045430753380060196, -0.018919697031378746, -0.039404623210430145, 0.040617674589157104, -0.005006284918636084, 0.02336103282868862, -0.06288304924964905, 0.019614268094301224, -0.005771779455244541, 0.02995455637574196, -0.059165630489587784, -0.027293669059872627, 0.023497989401221275, 0.016160981729626656, 0.03408284857869148, -0.015221845358610153, 0.02670670859515667, 0.03271327167749405, -0.003781004576012492, 0.0024896913673728704, -0.0068674394860863686, 0.05791344866156578, 0.00036104192258790135, 0.06663959473371506, -0.017256641760468483, 0.023576252162456512, -0.024339299649000168, -0.00478862039744854, 0.0001491094008088112, -0.02242189645767212, 0.0008437559008598328, 0.029895860701799393, -0.032380662858486176, -0.03375023603439331, -0.03478720039129257, -0.007473965175449848, -0.019751224666833878, -0.028898028656840324, -0.015290324576199055, -0.015075105242431164, -0.002317271661013365, -0.007537552621215582, -0.021247973665595055, -0.008789734914898872, -0.03529589995741844, -0.018097952008247375, -0.0007422605995088816, -0.015084887854754925, 0.0233414676040411, -0.026256704702973366, 0.015847936272621155, -0.005003839265555143, -0.007650053594261408, 0.014253360219299793, -0.030658910050988197, 0.013059874065220356, -0.027137145400047302, -0.010897901840507984, 0.023517556488513947, -0.0011953208595514297, 0.015329455025494099, 0.01969252899289131, 0.03556981310248375, 0.07180485129356384, 0.013901184312999249, -0.01534902025014162, -0.003944864496588707, -0.0010375751880928874, -0.013969662599265575, -0.020915362983942032, -0.007601140066981316, 0.006642437539994717, 0.0007410377729684114, 0.0201718807220459, 0.007796793710440397, -0.0460568442940712, -0.01752077415585518, -0.004028017167001963, -0.0011372362496331334, 0.025141479447484016, 0.07368312031030655, 0.0540003776550293, -0.044922053813934326, 0.03243935853242874, -0.01744251325726509, -0.050909049808979034, -0.009616371244192123, 0.018088169395923615, -0.02731323428452015, 0.010115288197994232, -0.0030864346772432327, 0.015681631863117218, 0.007165811024606228, 0.017892517149448395, 0.020974060520529747, -0.01764794997870922, -0.0056788441725075245, -0.05736561864614487, 0.01701207458972931, -0.04241768643260002, -0.007126680109649897, -0.0036342644598335028, 0.01752077415585518, -0.042574211955070496, -0.026237139478325844, -0.041322026401758194, 0.035119809210300446, 0.0432003028690815, -0.012834872119128704, 0.00866256095468998, 0.018694695085287094, 0.010966381058096886, 0.02852628566324711, -0.006383196916431189, 0.010457681491971016, 0.0015297661302611232, -0.06491784751415253, 0.0711396262049675, -0.002900563646107912, -0.05180905759334564, -0.01733490452170372, -0.01763816736638546, -0.02435886673629284, -0.002932357368990779, 0.029093680903315544, -0.02547409199178219, -0.01116203423589468, 0.052669934928417206, -0.017197946086525917, 0.07673531770706177, 0.01533923763781786, -0.020113183185458183, 0.03558937832713127, -0.03764374181628227, -0.01997622661292553, 0.09540066868066788, -0.046839457005262375, -0.023067552596330643, 0.03956114500761032, -0.005321776494383812, 0.00913212914019823, 0.010262028314173222, 0.004754381254315376, -0.01946752704679966, 0.013969662599265575, 0.0032478487119078636, 0.015945764258503914, -0.0070386361330747604, -0.02314581349492073, -0.016385983675718307, -0.033593714237213135, -0.02160015143454075, -0.011944648809731007, 0.019320787861943245, -0.014272925443947315, 0.001880719675682485, -0.009919634088873863, -0.008985389024019241, 0.00942560937255621, -0.029230639338493347, 0.02966107614338398, 0.02559148333966732, -0.026843665167689323, -0.042769864201545715, 0.00785548985004425, -0.016141416504979134, 0.02537626400589943, -0.05419602990150452, -0.0021032756194472313, 0.02835019864141941, -0.027352364733815193, -0.01823491044342518, 0.025024088099598885, 0.0034899699967354536, -0.002770943334326148, 0.008378863334655762, -0.029837165027856827, -0.05036121979355812, 0.055213429033756256, -0.017178380861878395, 0.004957371391355991, 0.04597858339548111, -0.04304377734661102, -0.023302337154746056, 0.0036758407950401306, -0.005517429672181606, 0.03893505409359932, 0.038876358419656754, -0.008075599558651447, 0.036645907908678055, -0.031852398067712784, -0.014859886839985847, 0.031148044392466545, 0.01805882155895233, -0.01793164759874344, -0.00979246012866497, 0.008794626221060753, -0.04003071412444115, -0.01612185128033161, 0.02926976978778839, -0.017491426318883896, -0.0011029968736693263, -0.03979593142867088, 0.022754507139325142, -0.004808185622096062, 0.03619590401649475, -0.026882797479629517, -0.006314718164503574, -0.001715637044981122, -0.06973092257976532, 0.05576125904917717, -0.015652284026145935, -0.018684912472963333, -0.018205562606453896, -0.05086991935968399, -0.004592966753989458, -0.016376201063394547, -0.031148044392466545, 0.05740474909543991, 0.016982726752758026, -0.02496539242565632, 0.028467589989304543, 0.007146245799958706, 0.0004414432914927602, -0.0009348570602014661, -0.020856667309999466, -0.04269160330295563, 0.01826425828039646, 0.010565291158854961, -0.02169797755777836, 0.01640554890036583, -0.003560894401744008, 0.021150147542357445, -0.03120674006640911, 0.026354532688856125, -0.0037565480452030897, -0.009753328748047352, 0.03357414901256561, -0.019937096163630486, -0.03016977570950985, 0.008559842593967915, 0.0011140023125335574, -0.021228408440947533, 0.04140029102563858, -0.0028761071152985096, 0.010663118213415146, -0.027763238176703453, -0.02977846935391426, 0.009518545120954514, 0.014008793979883194, 0.004394867457449436, -0.01864578202366829, -0.00794842466711998, 0.010203332640230656, 0.01376422680914402, -0.09446153044700623, -0.012737045995891094, -0.00011777425970649347, 0.012512044049799442, -0.014155534096062183, 0.048678599298000336, -0.004020680207759142, -0.02488712966442108, 0.024417562410235405, 0.02375233918428421, -0.0039595384150743484, -0.03271327167749405, -0.004365519620478153, -0.054782990366220474, -0.006891896016895771, 0.03854374587535858, 0.021991457790136337, 0.005771779455244541, -0.05118296667933464, 0.0026511054020375013, -0.010007678531110287, -0.0311089139431715, -0.020719710737466812, 0.03580459952354431, 0.045313358306884766, 0.020621882751584053, 0.0017938984092324972, 0.019751224666833878, -0.006035911850631237, 0.02672627381980419, -0.0004860767803620547, 0.06178738921880722, -0.05270906537771225, 0.01340226735919714, -0.04726989567279816, 0.013695747591555119, 0.030228471383452415, 0.007640270981937647, 0.012922916561365128, 0.007332116365432739, 0.0031059999018907547, -0.01887078396975994, -0.028408894315361977, 0.01600445993244648, 0.014409882947802544, 0.028995854780077934, 0.06339174509048462, 0.04636988788843155, 0.006921243853867054, 0.00845712423324585, -0.009753328748047352, -0.01833273656666279, -0.004316606093198061, -0.014155534096062183, -0.012874002568423748, -0.004715250339359045, -0.019105568528175354, 0.016072938218712807, -0.007356573361903429, 0.012267476879060268, 0.04116550460457802, 0.01578924059867859, 0.0037858961150050163, 0.006603307090699673, 0.038074180483818054, -0.03691982477903366, -0.00279050855897367, 0.012198998592793941, -0.005625039339065552, 0.015926199033856392, -0.04691771790385246, 0.043082911521196365, -0.0024896913673728704, 0.038993749767541885, 0.01866534724831581, -0.002646214095875621, 0.0068772220984101295, -0.045626405626535416, 0.013529442250728607, -0.0328502282500267, 0.005145688075572252, -0.002077596029266715, 0.023087117820978165, -0.18313170969486237, 0.0010864885989576578, -0.04625249654054642, -0.003397034713998437, -0.00560547411441803, -0.007151137106120586, 0.04523509740829468, -0.029602380469441414, 0.001450281823053956, -0.03709591180086136, -0.05544821545481682, 0.008775060996413231, 0.006275587249547243, -0.003140239277854562, 0.01876317523419857, 0.03312414512038231, 0.027958890423178673, 0.015026192180812359, -0.03770243749022484, 0.024906694889068604, 0.013500094413757324, 0.006691351067274809, 0.005468516610562801, 0.011846821755170822, -0.03261544555425644, -0.011435949243605137, 0.011709864251315594, 0.01504575740545988, -0.03089369460940361, 0.020015357062220573, 0.03609807789325714, -0.015417499467730522, 0.014028359204530716, 0.02660888247191906, 0.007439726032316685, -0.01085877139121294, 0.007684292737394571, -0.06378305703401566, 0.021639281883835793, 0.0026535510551184416, -0.02995455637574196, 0.034317631274461746, -0.03993288800120354, -0.01682620495557785, 0.06476132571697235, -0.012551174499094486, -0.0003133513673674315, -0.007987556047737598, -0.05012643709778786, 0.006378305610269308, -0.015388150699436665, 0.01998600922524929, 0.001583570847287774, -0.00906364992260933, -0.023830601945519447, 0.03283066302537918, -0.021971892565488815, -0.012688132002949715, -0.008731039240956306, 0.019526222720742226, -0.014282708056271076, 0.009298434481024742, -0.02864367887377739, -0.01988818310201168, -0.05568299815058708, 0.02885889820754528, -0.05756127089262009, 0.060496073216199875, 0.002497028326615691, 0.01640554890036583, -0.029895860701799393, 0.009166368283331394, 0.02680453471839428, -0.03138282895088196, 0.006569067481905222, 0.009538110345602036, 0.00040750965126790106, 0.011641385965049267, 0.001494303927756846, -0.0479351170361042, 0.0009293543407693505, -0.012981612235307693, -0.02028927206993103, 0.052435148507356644, 0.030052384361624718, 0.041556812822818756, 0.01248269621282816, -0.015290324576199055, -0.0473090261220932, -0.0074005951173603535, -0.03466980904340744, 0.003132902318611741, 0.006935918238013983, -0.0009379141847603023, -0.002912792144343257, 0.035726334899663925, -0.023321902379393578, -0.003042412456125021, 0.0019051763229072094, -0.00913212914019823, -0.029113246127963066, 0.0032038267236202955, 0.008716365322470665, 0.02028927206993103, -0.011455514468252659, 0.048795994371175766, 0.005116340238600969, 0.005488081835210323, 0.014899017289280891, 0.02181537076830864, -0.04574379697442055, -0.010575073771178722, 0.012208781205117702, -0.011504428461194038, -0.07759619504213333, 0.0214240625500679, -0.0018281377851963043, 0.011885952204465866, 0.0018611543346196413, -0.005292428191751242, 0.005898954346776009, -0.020661013200879097, 0.011641385965049267, -0.014096837490797043, 0.02641322836279869, -0.0025214850902557373, 0.015681631863117218, 0.003568231360986829, -0.037663307040929794, -0.020308837294578552, 0.023889297619462013, -0.021267540752887726, 0.031226305291056633, 0.019751224666833878, 0.002495805500075221, -0.005370689556002617, -0.021541455760598183, 0.035941556096076965, -0.015417499467730522, 0.0073810298927128315, -0.0261980090290308, -0.03161761164665222, -0.011543558910489082, -0.0020714818965643644, 0.0022267817985266447, 0.0127859590575099, 0.00978756882250309, 0.009993004612624645, -0.014918582513928413, 0.00993430893868208, 0.03465024381875992, -0.0255719181150198, 0.004446226637810469, 0.0033261103089898825, -0.024691477417945862, 0.00624623941257596, 0.012541391886770725, 0.011475080624222755, -0.014360969886183739, 0.04648728296160698, -0.016904465854167938, -0.01101529411971569, -0.026941493153572083, 0.008114730939269066, -0.02375233918428421, 0.06045694276690483, 0.003098662942647934, -0.016376201063394547, -0.034708939492702484, 0.017872951924800873, 0.038895923644304276, -0.022363198921084404, -0.016777291893959045, 0.0038543748669326305, 0.013656617142260075, 0.002736703958362341, -0.01406748965382576, 0.030561083927750587, 0.03586329519748688, 0.01259030494838953, 0.02140449732542038, 0.013989227823913097, 0.03783939406275749, -0.004624760709702969, 0.0005325445090420544, 0.05583951994776726, -0.02050449140369892, 0.009352238848805428, 0.0024750172160565853, -0.010222897864878178, 0.016356635838747025, 0.009748437441885471, -0.02253928780555725, 0.009176150895655155, 0.06808742880821228, 0.035217639058828354, -0.005507647059857845, -0.012570739723742008, -0.0027440409176051617, 0.032674141228199005, -0.0003937527653761208, -0.004614978097379208, -0.0065446109510958195, -0.028487155213952065, -0.03680242970585823, -0.01812729984521866, 0.016963161528110504, 0.0004701799189206213, -0.025434959679841995, 0.023811036720871925, 0.0204849261790514, -0.02193276211619377, 0.0014478361699730158, 0.034611109644174576, 0.026158878579735756, 0.005131014157086611, -0.0004475574824027717, 0.05282645672559738, 0.010506595484912395, -0.0004240178968757391, -0.004920686595141888, 0.012864219956099987, 0.013871836476027966, -0.022695811465382576, -0.014468579553067684, -0.008657669648528099, -0.0239675585180521, 0.007014179602265358, 0.010672900825738907, -0.019193612039089203, -0.006378305610269308, 0.00608971668407321, -0.01330444123595953, 0.01621967926621437, 0.02099362574517727, 0.03189152851700783, 0.05008730664849281, 0.015437064692378044, -0.016170764341950417, -0.021052321419119835, 0.007938642054796219, 0.005238623358309269, -0.006304935552179813, 0.022715376690030098]\n",
      "[[-0.050539933145046234, 0.027052080258727074, -0.0674399733543396, -0.028633955866098404, -0.04697570577263832, -0.05142097920179367, 0.019102653488516808, 0.09651445597410202, -0.029174596071243286, 0.008640246465802193, -0.010942976921796799, 0.025490228086709976, -0.0060822125524282455, -0.04809703677892685, 0.01114321406930685, -0.0213052649050951, 0.041288964450359344, -0.03886609151959419, 0.023307640105485916, -0.03440079465508461, -0.04961884021759033, -0.0022176296915858984, -0.0292146448045969, 0.03400031849741936, 0.07376747578382492, 0.041969768702983856, -0.004750633612275124, -0.06403593719005585, -0.027652792632579803, -0.04969893768429756, 0.040988605469465256, 0.035562172532081604, -0.011683855205774307, -0.056346818804740906, -0.01806141808629036, 0.0059620700776577, 0.0040047490037977695, 0.014226870611310005, -0.10572537779808044, 0.0033464685548096895, -0.0008128389017656446, 0.06323498487472534, 0.025390109047293663, -0.009406154043972492, -0.0069031864404678345, -0.040908511728048325, -0.012584923766553402, -0.05846933647990227, -0.020374160259962082, -0.025870678946375847, -0.010502454824745655, -0.0237882100045681, 0.04229015111923218, -0.06623855233192444, 0.03438077121973038, 0.023367710411548615, -0.03582248091697693, -0.06900182366371155, -0.048817891627550125, 0.036162883043289185, -0.015678592026233673, -0.009726534597575665, -0.011493629775941372, -0.032698776572942734, -0.0019185250857844949, 0.07753194123506546, -0.03199794515967369, -0.006297467742115259, 0.0005021580145694315, 0.034961458295583725, 0.0024992136750370264, 0.010312228463590145, -0.01641947031021118, -0.013455957174301147, -0.049178317189216614, 0.005246221087872982, 0.06179327890276909, -0.03313929960131645, 0.00998684298247099, 0.02392837591469288, 0.14080697298049927, 0.009926771745085716, 0.020664505660533905, -0.025650417432188988, -0.009951801039278507, 0.05778852850198746, -0.009946795180439949, 0.04381195455789566, 0.019132688641548157, -0.004720597993582487, -0.04981907829642296, -0.05110059678554535, 0.03674357384443283, -0.035341911017894745, -0.0012727592838928103, 0.010602572932839394, 0.04637499526143074, 0.048297274857759476, 0.0009148348472081125, -0.01178397424519062, 0.005286268889904022, 0.07036343961954117, 0.021185122430324554, -0.06415607780218124, 0.0013340819859877229, 0.03824535384774208, -0.014126752503216267, 0.02400847151875496, -0.01114321406930685, -0.03400031849741936, 0.06255418062210083, 0.027272341772913933, -0.016379423439502716, -0.000986795173957944, -0.03369996324181557, -0.04080839455127716, 0.008299842476844788, -0.03191785141825676, -0.03922651708126068, 0.0003285145794507116, 0.0049909185618162155, 0.04405223950743675, 0.042930908501148224, -0.057708434760570526, -0.04601456597447395, -0.03612283617258072, 0.0273123886436224, 0.028954336419701576, -0.0005465856520459056, 0.004422744736075401, 0.060631901025772095, 0.021125052124261856, -0.021585596725344658, -0.005421428941190243, -0.037985045462846756, -0.055425725877285004, 0.04018765687942505, -0.004342649597674608, -0.029995569959282875, -0.07064377516508102, 0.052582357078790665, 0.0445728562772274, 0.011283380910754204, 0.00041079966467805207, 0.030596282333135605, -0.07757198810577393, 0.027452554553747177, 0.033239416778087616, -0.006487693637609482, -0.02687186561524868, 0.01689002849161625, -0.024969611316919327, 0.020414208993315697, 0.031116900965571404, 0.007078393828123808, 0.01185405720025301, -0.014437120407819748, 0.03968706354498863, -0.019382985308766365, 0.017220420762896538, 0.05734800547361374, -0.014256906695663929, -0.013866443186998367, -0.015538426116108894, -0.015368224121630192, 0.016839969903230667, -0.028173409402370453, -0.012124378234148026, -0.03440079465508461, -0.022246381267905235, 0.013135576620697975, -0.06980277597904205, 0.03079652041196823, -0.02522991970181465, 0.008054551668465137, 0.03658338263630867, 0.01795128732919693, -0.0026606551837176085, 0.0387459471821785, -0.07965446263551712, -0.0495387464761734, 0.007363732438534498, -0.016649743542075157, -0.022326476871967316, -0.026851842179894447, -0.024929562583565712, -0.003258864628151059, 0.001750826253555715, -0.011613772250711918, 0.05718781799077988, -0.024969611316919327, -0.004980906844139099, -0.024448992684483528, 0.008800435811281204, 0.016499565914273262, -0.006637871731072664, 0.033920224756002426, -0.06159304082393646, -0.049578793346881866, 0.037824854254722595, -0.04809703677892685, 0.01806141808629036, -0.018071429803967476, -0.009971825405955315, -0.03253858536481857, -0.03087661601603031, -0.05466482415795326, -0.04801694303750992, 0.003601771080866456, 0.0039621987380087376, -0.010792798362672329, -0.03544202819466591, -0.008159676566720009, -0.006237396504729986, -0.024889515712857246, 0.012434746138751507, 0.0036242979113012552, -0.03514167293906212, -0.004878284875303507, -0.02364804409444332, 0.032318323850631714, 0.004587940871715546, 0.03634309768676758, 0.05382382869720459, 0.025169847533106804, 0.002178833819925785, 0.0901869460940361, 0.0099167600274086, 0.0035817474126815796, -0.03892616182565689, -0.011303404346108437, -0.003952186554670334, 0.00562667241320014, -0.022746974602341652, 0.008870518766343594, -0.00248920195735991, -0.02054436318576336, 0.0367235504090786, 0.0101920859888196, -0.014917690306901932, -0.03984725475311279, -0.026971984654664993, -0.00722857192158699, -0.01354606356471777, -0.00013672462955582887, 0.021805858239531517, 0.01087289396673441, -0.026451367884874344, 0.002108750632032752, -0.0009573853458277881, 0.006237396504729986, -0.029915476217865944, -0.0004918332560919225, 0.020143887028098106, 0.04321124404668808, 0.015598497353494167, 0.023127425462007523, 0.007543946150690317, 0.036383144557476044, -0.0034741198178380728, 0.05246221274137497, -0.010702691972255707, -0.002885922323912382, 0.03520174324512482, -0.019843531772494316, -0.01877226121723652, -0.031176971271634102, -0.027652792632579803, -0.006087218411266804, 0.02490953914821148, 0.03107685223221779, -0.020604433491826057, -0.03283894062042236, -0.0318177305161953, -0.006883162539452314, 0.0030736448243260384, -0.03930661082267761, -0.07244591414928436, 0.026591533794999123, 0.020644482225179672, 0.04269062355160713, -0.004980906844139099, 0.05110059678554535, 0.027572697028517723, -0.021946024149656296, 0.026391295716166496, -0.007403779774904251, -0.011944164521992207, 0.045894425362348557, -0.019443057477474213, 0.015488366596400738, 0.01554843783378601, 0.06579802930355072, -0.017230432480573654, -0.036162883043289185, -0.006878156680613756, 0.006107242312282324, -0.20472277700901031, 0.022746974602341652, 0.0010894169099628925, -0.003721913555637002, 0.005611654836684465, 0.01584879495203495, -0.014557262882590294, 0.03101678192615509, -0.0228070467710495, -0.0024328851141035557, -0.033299487084150314, -0.04164939001202583, -0.056947533041238785, -0.015588485635817051, 0.00298103503882885, 0.009331065230071545, -0.016079068183898926, 0.0022539228666573763, 0.006833103019744158, -0.03141725808382034, -0.008304848335683346, 0.0018546994542703032, 0.04229015111923218, -0.03418053314089775, -0.037904951721429825, -0.011954176239669323, 0.03115694783627987, 0.009871706366539001, -0.022406570613384247, 0.024268779903650284, -0.011984211392700672, 0.01721040904521942, -0.010157044976949692, 0.011113178916275501, -0.011803997680544853, 0.012745114043354988, -0.005040978081524372, 0.005766838788986206, 0.015788722783327103, 0.015288129448890686, 0.030736448243260384, 0.030676377937197685, 0.01087289396673441, 0.021805858239531517, 0.007919391617178917, -0.01773102581501007, -0.0066278595477342606, 0.008079580962657928, -0.03614285960793495, -0.043171193450689316, 0.00822475366294384, 0.005196162033826113, 0.03950684890151024, 0.01200423575937748, -0.017110290005803108, 0.033159323036670685, -0.008109617047011852, 0.004450277425348759, -0.03912639990448952, -0.019823508337140083, -0.04541385546326637, -0.019623270258307457, 0.036403167992830276, 0.04593447223305702, 0.0006335638463497162, -0.02362801879644394, -0.00815467070788145, -0.00671796640381217, 0.0020236498676240444, -0.02430882677435875, 0.029174596071243286, -0.011553701013326645, 0.010111991316080093, 0.01986355520784855, -0.011313416063785553, -0.02138536050915718, 0.02062445692718029, -0.0016069056000560522, -0.04893803223967552, -0.12999415397644043, -0.05486506223678589, 0.017040207982063293, 0.005441452842205763, 0.04409228637814522, -0.016129126772284508, -0.04050803557038307, -0.05090036243200302, 0.007373744156211615, 0.015107915736734867, 0.2684783637523651, 0.029074478894472122, 0.014507203362882137, 0.03351974859833717, 0.06403593719005585, -0.0013578602811321616, -0.014377049170434475, -0.002570548327639699, -0.0012589929392561316, -0.012044282630085945, 0.021865930408239365, 0.006377562880516052, 0.02258678525686264, -0.023427782580256462, 0.016219234094023705, 0.02468927763402462, -0.02422873117029667, 0.004300099331885576, 0.06067194789648056, 0.012955362908542156, 0.016870005056262016, -0.001435452257283032, 0.0376446396112442, 0.020604433491826057, -0.010973012074828148, -0.02498963475227356, 0.010712703689932823, 0.027052080258727074, 0.013606134802103043, 0.005151108372956514, 0.001793376635760069, -0.015788722783327103, -0.0007483874796889722, 0.0009598882752470672, -0.0022589287254959345, 0.004154927097260952, 0.02452908828854561, -0.017070243135094643, -0.005957064218819141, -0.0301958080381155, -0.03656335920095444, -0.03802509233355522, 0.009010685607790947, 0.021946024149656296, 0.019663317129015923, -0.03416050970554352, -0.007098417729139328, -0.06607835739850998, -0.011493629775941372, -0.04473304748535156, 0.0005860074306838214, 0.00017051470058504492, -0.03558219596743584, 0.02709212712943554, -0.002210120903328061, -0.012044282630085945, -0.01760087162256241, -0.03958694636821747, -0.04841741546988487, 0.028794145211577415, 0.037524498999118805, 0.02220633439719677, -0.04032782465219498, 0.04014761000871658, -0.00013781969028059393, -0.0016769886715337634, -0.013756313361227512, -0.02867400273680687, 0.026851842179894447, 0.029975546523928642, -0.009921765886247158, -0.0029610113706439734, 0.004552898928523064, 0.013846419751644135, -0.0016356897540390491, -0.024969611316919327, -0.014166799373924732, 0.03151737526059151, 0.004230016376823187, 0.050179507583379745, 0.017200397327542305, -0.03147732838988304, -0.0292146448045969, -0.014987773261964321, 0.0029509994201362133, -0.009981837123632431, -0.06007123738527298, 0.05602644011378288, -0.033539772033691406, -0.04225010424852371, 0.0013616146752610803, -0.014256906695663929, -0.010822834447026253, 0.022626832127571106, -0.04489323869347572, -0.034060392528772354, -0.004280075430870056, 0.016839969903230667, 0.0037844879552721977, 0.00348162860609591, -0.047976892441511154, -0.013906490989029408, -0.0032063021790236235, 0.02054436318576336, 0.04281076788902283, -0.04144915193319321, 0.0016031510895118117, -0.0292747151106596, -9.260982187697664e-05, 0.0034140485804528, 0.031637515872716904, -0.028934311121702194, -0.028774121776223183, 0.014306966215372086, 0.023988446220755577, 0.01749074086546898, 0.0016744857421144843, 0.02468927763402462, -0.009496261365711689, 0.03508160263299942, 0.029034430161118507, 0.004783172160387039, -0.014276930131018162, 0.04525366425514221, -0.03133716061711311, -0.03468112647533417, -0.0237882100045681, 0.02424875646829605, -0.01012200303375721, 0.01080281101167202, -0.0292146448045969, -0.0213052649050951, 0.02400847151875496, 0.044813141226768494, 0.06551769375801086, -0.012765137478709221, 0.06727978587150574, -0.000845377508085221, -0.018431857228279114, 0.027432531118392944, -0.0015743669355288148, -0.02583063207566738, -0.037604592740535736, 0.005907004699110985, 0.010892917402088642, 0.009080768562853336, -0.027532650157809258, -0.0005381381488405168, 0.044452715665102005, 0.06968263536691666, -0.011133202351629734, -0.0163093414157629, 0.003138722153380513, -0.03185777738690376, 0.009861694648861885, -0.007944420911371708, -0.00820973515510559, -0.0016957609914243221, 0.029034430161118507, -0.0405881330370903, -0.004432756453752518, 0.025249943137168884, 0.037364307790994644, 0.05262240394949913, 0.03914642333984375, 0.0048507521860301495, 0.028954336419701576, -0.02356794849038124, -0.0021012418437749147, -0.05066007748246193, 0.004933350253850222, -0.03167756646871567, -0.054905109107494354, 0.018341749906539917, -0.020274043083190918, -0.03115694783627987, -0.02048429101705551, -0.014757500030100346, -0.01347598060965538, -0.014767511747777462, 0.02114507555961609, -0.0021900972351431847, 0.00978159997612238, -0.01789121702313423, -0.024068541824817657, 0.03303917869925499, 0.032558608800172806, -0.019102653488516808, 0.046254850924015045, -0.01991361565887928, -0.018672142177820206, 0.10516471415758133, 0.04449276253581047, -0.019623270258307457, 0.02619105949997902, 0.008174694143235683, 0.016109103336930275, 0.022947212681174278, 0.0012452267110347748, -0.010116997174918652, 0.007283637300133705, -0.04517357051372528, 0.0018534478731453419, 0.02212623879313469, -0.009996854700148106, 0.015177998691797256, -0.0301958080381155, 0.029294738546013832, -0.023427782580256462, 0.024929562583565712, 0.010452395305037498, -0.019713377580046654, -0.0011932901106774807, -0.014897666871547699, -0.01562853343784809, 0.0024729324504733086, 0.05029964819550514, 0.08562153577804565, -0.00033445912413299084, -0.06215370446443558, -0.03301915526390076, 0.009486249648034573, -0.023307640105485916, -0.010262169875204563, 0.05478496849536896, 0.043091099709272385, 0.017590859904885292, -0.02454911172389984, 0.056266725063323975, -0.006192343309521675, -0.003546705935150385, -0.0017883707769215107, 0.03297910839319229, -0.03720412030816078, 0.04689561203122139, -0.03876597061753273, 0.0083999615162611, 0.03816526010632515, 0.019302889704704285, 0.006732984445989132, 0.03746442869305611, -0.03265872970223427, 0.02551025152206421, 0.05158116668462753, -0.0027107144705951214, -0.011383499018847942, -0.014176812022924423, -0.05526553839445114, -0.024789396673440933, 0.04817713052034378, -0.009711516089737415, 0.008064563386142254, -0.005546577274799347, -0.007839296013116837, -0.03347970172762871, -0.02070455253124237, 0.01652960106730461, -0.02400847151875496, -0.005326316226273775, 0.04489323869347572, 0.045053426176309586, 0.010622597299516201, -0.0248294435441494, -0.01776106283068657, -0.04421243071556091, -0.020764624699950218, 0.0247693732380867, -0.022406570613384247, -0.028994383290410042, -0.05802881345152855, -0.005997111555188894, -0.006953245494514704, -0.02236652374267578, -0.022146262228488922, 0.037684690207242966, 0.024969611316919327, -0.0016682283021509647, 0.020884767174720764, 0.0071284533478319645, 0.03882604092359543, -0.009421172551810741, -0.002079966478049755, -0.016809934750199318, 0.021625645458698273, -0.029234668239951134, 0.049578793346881866, 0.032418444752693176, 0.03153739869594574, -0.014767511747777462, -0.03930661082267761, 0.00838994886726141, -0.019593235105276108, -0.044132333248853683, -0.0237882100045681, -0.024749349802732468, 0.020233994349837303, 0.007704135961830616, -0.0015380739932879806, -0.04833732172846794, 0.025610370561480522, -0.0026556493248790503, 0.02364804409444332, -0.0377647839486599, -0.013736288994550705, 0.027913101017475128, 0.027132175862789154, 0.017230432480573654, -0.01719038560986519, 0.03554214909672737, 0.010332252830266953, 0.020193947479128838, -0.0407683439552784, 0.007253601681441069, 0.03596264496445656, 0.013325802981853485, -0.035682313144207, 0.07629047334194183, -0.06972268223762512, -0.00248920195735991, 0.014437120407819748, 0.08393953740596771, 0.012805185280740261, 0.009446201846003532, 0.022006096318364143, -0.028413694351911545, 0.015218046493828297, -0.04032782465219498, 0.02234650030732155, -0.003441581269726157, 0.003719410626217723, -0.034060392528772354, -0.01445714384317398, 0.001198295969516039, -0.027452554553747177, 0.010422359220683575, 0.02741250768303871, 0.04733613505959511, -0.008840483613312244, 0.02867400273680687, 0.011994223110377789, 0.01770099066197872, 0.016619708389043808, 0.04725603759288788, -0.0005534688243642449, 0.030095688998699188, -0.017500752583146095, -0.021105026826262474, -0.005731797311455011, 0.024869492277503014, 0.023127425462007523, -0.01738061010837555, 0.017200397327542305, -0.03846561536192894, -0.023908352479338646, 0.035281840711832047, 0.011453581973910332, -0.006152295973151922, 0.004525366239249706, -0.006257420405745506, -0.022526713088154793, -0.01999370940029621, 0.004640502855181694, -0.027612745761871338, -0.003308923915028572, -0.01069268025457859, 0.01986355520784855, 0.018051406368613243, 0.04417238384485245, -0.003489137627184391, 0.00647267559543252, -0.048978082835674286, 0.0292146448045969, 0.027212269604206085, 0.008204729296267033, -0.03806513920426369, 0.050019316375255585, -0.0028884252533316612, 0.007283637300133705, 0.056266725063323975, -0.0222864281386137, -0.033379584550857544, -0.034881364554166794, -0.04717594385147095, -0.02613098733127117, 0.04569418728351593, -0.027192246168851852, -0.0024654236622154713, 0.022406570613384247, 0.044132333248853683, -0.029074478894472122, 0.008995668031275272, -0.02364804409444332, -0.0004148669831920415, 0.012144401669502258, -0.14465153217315674, 0.007523922249674797, 0.014697428792715073, 0.0003726293798536062, -0.003859577002003789, -0.008655264042317867, -0.030996758490800858, 0.02665160596370697, -0.008384943008422852, -0.03223823010921478, -0.03870590031147003, 0.02763276919722557, 0.0035166703164577484, -0.006878156680613756, 0.00010160486272070557, 0.0054564704187214375, -0.021465454250574112, -0.0066879307851195335, -0.020444244146347046, 0.023067355155944824, -0.03171761333942413, 0.026611557230353355, 0.037524498999118805, 0.01749074086546898, 0.001646953052841127, -0.020254017785191536, 0.02687186561524868, 0.0013553572352975607, -0.0048532551154494286, -0.0057368031702935696, -0.003118698252364993, -0.010442383587360382, 0.007243589963763952, 0.022006096318364143, 0.026451367884874344, 0.013836408033967018, 0.009981837123632431, 0.014026633463799953, -0.0022464138455688953, -0.012444757856428623, -0.016139138489961624, 0.005316304508596659, -0.042730674147605896, -0.012544876895844936, -0.003499149577692151, -0.0016294323140755296, -0.007343708537518978, 0.03161749243736267, -0.004675544332712889, 0.009621409699320793, -0.0020974872168153524, -0.0031912843696773052, -0.002207617973908782, 0.028774121776223183, -0.00613727793097496, 0.0086752874776721, -0.0071885245852172375, -0.021805858239531517, -0.018612071871757507, 0.0476965606212616, 0.0008948111208155751, 0.008845489472150803, -0.03233834728598595, -0.003586753271520138, -0.00425003981217742, -0.017170362174510956, -0.05218188092112541, -0.01080281101167202, -0.019032569602131844, -0.010522478260099888, -0.0407683439552784, 0.020664505660533905, -0.02108500339090824, -0.0006701697129756212, 0.014126752503216267, -0.021645668894052505, 0.027232293039560318, -0.016629720106720924, -0.04024772718548775, 0.018612071871757507, -0.011934151872992516, 0.05021955445408821, -0.025870678946375847, 0.03281891718506813, -0.011513653211295605, 0.020584410056471825, -0.010292205028235912, 0.04389204829931259, -0.04697570577263832, -0.015107915736734867, -0.029334787279367447, -0.03259865567088127, 0.015718640759587288, -0.010932965204119682, 0.039626993238925934, 0.0023390238638967276, -0.0446930006146431, -0.030295927077531815, -0.003196290461346507, -0.03221820667386055, -0.03756454586982727, 0.015818757936358452, -0.0008572665974497795, 0.02266687899827957, 0.003198793390765786, -0.012775149196386337, 0.03950684890151024, 0.018762249499559402, 0.014266918413341045, 0.01611911505460739, 0.029675191268324852, -0.03608278930187225, -0.014697428792715073, 0.01798132248222828, -0.02559034712612629, -0.0016457015881314874, 0.017340563237667084, 0.0001739562867442146, 0.02949497662484646, -0.01185405720025301, -0.022406570613384247, 0.029855404049158096, -0.010642620734870434, -0.0396670401096344, 0.003123704344034195, -0.019873566925525665, -0.016729839146137238, -0.0008322368958033621, 0.03522176668047905, -0.004097358789294958, 0.019933639094233513, -0.011884093284606934, 0.011123190633952618, 0.00782928429543972, 0.04176953434944153, -0.03426062688231468, -0.02234650030732155, 0.04333138465881348, -0.02949497662484646, -0.012154413387179375, -0.012634983286261559, -0.013886467553675175, 0.02430882677435875, -0.00893559679389, 0.014507203362882137, -0.005331322085112333, 0.054384492337703705, 0.03357982262969017, -0.061552993953228, -0.006332509685307741, 0.007238584104925394, 0.049338508397340775, -0.010973012074828148, 0.007799248676747084, -0.03087661601603031, 0.033840131014585495, -0.03674357384443283, 0.01294535119086504, 0.06579802930355072, 0.00429008761420846, 0.01806141808629036, 0.0027132174000144005, 0.013325802981853485, 0.006732984445989132, -0.0011870326707139611, -0.0017070242902264, -0.016709815710783005, -0.020304078236222267, -0.030656354501843452, -0.04108872637152672, 0.0015931392554193735, 0.025029681622982025, 0.007649070583283901, -0.015578473918139935, -0.01562853343784809, -0.022546736523509026, 0.0257505364716053, -0.03576241061091423, 0.060792092233896255, 0.0027782947290688753, 0.018752237781882286, 0.022746974602341652, -0.002427879022434354, 0.01961325854063034, -0.014437120407819748, 0.03646324202418327, -0.03634309768676758, 0.03147732838988304, -0.016900040209293365, 0.05486506223678589, 0.015758687630295753, 0.0040022460743784904, -0.013536051847040653, 0.020584410056471825, 0.024669254198670387, 0.019463080912828445, 0.019002534449100494, -0.0052312035113573074, 0.027652792632579803, -0.012795173563063145, -0.0335998460650444, -0.023607995361089706, 0.003136219223961234, -0.039546895772218704, -0.026911914348602295, 0.01351602841168642, -0.0335998460650444, 0.008955620229244232, -0.028393670916557312, 0.0009811634663492441, -0.00984667707234621, -0.006252414546906948, 0.0046254852786660194, -0.026971984654664993, -0.00011818702478194609, -0.013335814699530602, 0.004109873902052641, -0.004450277425348759, -0.005866957362741232, -0.025930751115083694, 0.0016482045175507665, -0.02054436318576336, -0.02747257798910141, -0.04885793849825859, -0.017590859904885292, 0.004387703258544207, -0.0018622083589434624, 0.0015305650886148214, 0.006507717072963715, 5.172149030840956e-06, 0.01223450805991888, -0.0183617752045393, -0.024148637428879738, 0.009105797857046127, 0.019242819398641586, -0.011613772250711918, 0.015918876975774765, 0.02304733172059059, 0.0158788301050663, 0.00444777449592948, 0.004400217905640602, -0.0012226999970152974, -0.03848563879728317, 0.04094855859875679]]\n",
      "✓ Embedding 模型初始化完成\n",
      "  模型: text-embedding-v3\n",
      "  维度: 1024\n",
      "  API 端点: https://dashscope.aliyuncs.com/compatible-mode/v1\n"
     ]
    }
   ],
   "source": [
    "# 初始化 embedding 模型\n",
    "from langchain_community.embeddings import DashScopeEmbeddings\n",
    "\n",
    "EMBEDDING_URL = \"https://dashscope.aliyuncs.com/compatible-mode/v1\"\n",
    "EMBEDDING_KEY = \"sk-8d7ac86d58cd49c8966a0aeea75f1c28\"\n",
    "EMBEDDING_MODEL = \"text-embedding-v3\"\n",
    "\n",
    "embeddings = DashScopeEmbeddings(\n",
    "    model=\"text-embedding-v3\", dashscope_api_key=EMBEDDING_KEY\n",
    ")\n",
    "\n",
    "text = \"This is a test document.\"\n",
    "\n",
    "query_result = embeddings.embed_query(text)\n",
    "print(query_result)\n",
    "\n",
    "doc_results = embeddings.embed_documents([\"foo\"])\n",
    "print(doc_results)\n",
    "\n",
    "\n",
    "print(\"✓ Embedding 模型初始化完成\")\n",
    "print(f\"  模型: {EMBEDDING_MODEL}\")\n",
    "print(f\"  维度: 1024\")\n",
    "print(f\"  API 端点: {EMBEDDING_URL}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b3b49d74",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_postgres import PGVector\n",
    "\n",
    "\n",
    "connection = (\n",
    "    f\"postgresql+psycopg://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}\"\n",
    "    f\":{POSTGRES_PORT}/{POSTGRES_DB}\"\n",
    ")\n",
    "\n",
    "collection_name = \"test_vectorstore\"\n",
    "\n",
    "vector_store = PGVector(\n",
    "    embeddings=embeddings,\n",
    "    collection_name=collection_name,\n",
    "    connection=connection,\n",
    "    use_jsonb=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d9837ac6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain_core.documents import Document\n",
    "\n",
    "docs = [\n",
    "    Document(\n",
    "        page_content=\"there are cats in the pond\",\n",
    "        metadata={\"id\": 1, \"location\": \"pond\", \"topic\": \"animals\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"ducks are also found in the pond\",\n",
    "        metadata={\"id\": 2, \"location\": \"pond\", \"topic\": \"animals\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"fresh apples are available at the market\",\n",
    "        metadata={\"id\": 3, \"location\": \"market\", \"topic\": \"food\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"the market also sells fresh oranges\",\n",
    "        metadata={\"id\": 4, \"location\": \"market\", \"topic\": \"food\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"the new art exhibit is fascinating\",\n",
    "        metadata={\"id\": 5, \"location\": \"museum\", \"topic\": \"art\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"a sculpture exhibit is also at the museum\",\n",
    "        metadata={\"id\": 6, \"location\": \"museum\", \"topic\": \"art\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"a new coffee shop opened on Main Street\",\n",
    "        metadata={\"id\": 7, \"location\": \"Main Street\", \"topic\": \"food\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"the book club meets at the library\",\n",
    "        metadata={\"id\": 8, \"location\": \"library\", \"topic\": \"reading\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"the library hosts a weekly story time for kids\",\n",
    "        metadata={\"id\": 9, \"location\": \"library\", \"topic\": \"reading\"},\n",
    "    ),\n",
    "    Document(\n",
    "        page_content=\"a cooking class for beginners is offered at the community center\",\n",
    "        metadata={\"id\": 10, \"location\": \"community center\", \"topic\": \"classes\"},\n",
    "    ),\n",
    "]\n",
    "\n",
    "vector_store.add_documents(docs, ids=[doc.metadata[\"id\"] for doc in docs])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "95f0aecc",
   "metadata": {},
   "outputs": [],
   "source": [
    "vector_store.delete(ids=[\"3\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b3a14f22",
   "metadata": {},
   "outputs": [],
   "source": [
    "results = vector_store.similarity_search(\n",
    "    \"kitty\", k=10, filter={\"id\": {\"$in\": [1, 5, 2, 9]}}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ead989ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "* there are cats in the pond [{'id': 1, 'topic': 'animals', 'location': 'pond'}]\n",
      "* the library hosts a weekly story time for kids [{'id': 9, 'topic': 'reading', 'location': 'library'}]\n",
      "* ducks are also found in the pond [{'id': 2, 'topic': 'animals', 'location': 'pond'}]\n",
      "* the new art exhibit is fascinating [{'id': 5, 'topic': 'art', 'location': 'museum'}]\n"
     ]
    }
   ],
   "source": [
    "for doc in results:\n",
    "    print(f\"* {doc.page_content} [{doc.metadata}]\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "231e64c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "retriever = vector_store.as_retriever(search_type=\"mmr\", search_kwargs={\"k\": 1})\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "3c2ce2e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(id='1', metadata={'id': 1, 'topic': 'animals', 'location': 'pond'}, page_content='there are cats in the pond')]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "retriever.invoke(\"kitty\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "table_config",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✓ 表名: test_vectorstore, 向量维度: 1024\n"
     ]
    }
   ],
   "source": [
    "# 表配置\n",
    "TABLE_NAME = \"test_vectorstore\"\n",
    "VECTOR_SIZE = 1024\n",
    "print(f\"✓ 表名: {TABLE_NAME}, 向量维度: {VECTOR_SIZE}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "init_table",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "❌ 初始化表失败: (sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.DuplicateTableError'>: relation \"test_vectorstore\" already exists\n",
      "[SQL: CREATE TABLE \"public\".\"test_vectorstore\"(\n",
      "            \"langchain_id\" UUID PRIMARY KEY,\n",
      "            \"content\" TEXT NOT NULL,\n",
      "            \"embedding\" vector(1024) NOT NULL\n",
      "            ,\n",
      "\"langchain_metadata\" JSON\n",
      ");]\n",
      "(Background on this error at: https://sqlalche.me/e/20/f405)\n"
     ]
    },
    {
     "ename": "ProgrammingError",
     "evalue": "(sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.DuplicateTableError'>: relation \"test_vectorstore\" already exists\n[SQL: CREATE TABLE \"public\".\"test_vectorstore\"(\n            \"langchain_id\" UUID PRIMARY KEY,\n            \"content\" TEXT NOT NULL,\n            \"embedding\" vector(1024) NOT NULL\n            ,\n\"langchain_metadata\" JSON\n);]\n(Background on this error at: https://sqlalche.me/e/20/f405)",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mDuplicateTableError\u001b[39m                       Traceback (most recent call last)",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:545\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor._prepare_and_execute\u001b[39m\u001b[34m(self, operation, parameters)\u001b[39m\n\u001b[32m    544\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m545\u001b[39m     \u001b[38;5;28mself\u001b[39m._rows = deque(\u001b[38;5;28;01mawait\u001b[39;00m prepared_stmt.fetch(*parameters))\n\u001b[32m    546\u001b[39m     status = prepared_stmt.get_statusmsg()\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\asyncpg\\prepared_stmt.py:176\u001b[39m, in \u001b[36mPreparedStatement.fetch\u001b[39m\u001b[34m(self, timeout, *args)\u001b[39m\n\u001b[32m    168\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33mr\u001b[39m\u001b[33;03m\"\"\"Execute the statement and return a list of :class:`Record` objects.\u001b[39;00m\n\u001b[32m    169\u001b[39m \n\u001b[32m    170\u001b[39m \u001b[33;03m:param str query: Query text\u001b[39;00m\n\u001b[32m   (...)\u001b[39m\u001b[32m    174\u001b[39m \u001b[33;03m:return: A list of :class:`Record` instances.\u001b[39;00m\n\u001b[32m    175\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m176\u001b[39m data = \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m.__bind_execute(args, \u001b[32m0\u001b[39m, timeout)\n\u001b[32m    177\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m data\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\asyncpg\\prepared_stmt.py:267\u001b[39m, in \u001b[36mPreparedStatement.__bind_execute\u001b[39m\u001b[34m(self, args, limit, timeout)\u001b[39m\n\u001b[32m    266\u001b[39m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__bind_execute\u001b[39m(\u001b[38;5;28mself\u001b[39m, args, limit, timeout):\n\u001b[32m--> \u001b[39m\u001b[32m267\u001b[39m     data, status, _ = \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m.__do_execute(\n\u001b[32m    268\u001b[39m         \u001b[38;5;28;01mlambda\u001b[39;00m protocol: protocol.bind_execute(\n\u001b[32m    269\u001b[39m             \u001b[38;5;28mself\u001b[39m._state, args, \u001b[33m'\u001b[39m\u001b[33m'\u001b[39m, limit, \u001b[38;5;28;01mTrue\u001b[39;00m, timeout))\n\u001b[32m    270\u001b[39m     \u001b[38;5;28mself\u001b[39m._last_status = status\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\asyncpg\\prepared_stmt.py:256\u001b[39m, in \u001b[36mPreparedStatement.__do_execute\u001b[39m\u001b[34m(self, executor)\u001b[39m\n\u001b[32m    255\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m256\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m executor(protocol)\n\u001b[32m    257\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m exceptions.OutdatedSchemaCacheError:\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\asyncpg\\protocol\\protocol.pyx:206\u001b[39m, in \u001b[36mbind_execute\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[31mDuplicateTableError\u001b[39m: relation \"test_vectorstore\" already exists",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[31mProgrammingError\u001b[39m                          Traceback (most recent call last)",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1967\u001b[39m, in \u001b[36mConnection._exec_single_context\u001b[39m\u001b[34m(self, dialect, context, statement, parameters)\u001b[39m\n\u001b[32m   1966\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m evt_handled:\n\u001b[32m-> \u001b[39m\u001b[32m1967\u001b[39m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdo_execute\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1968\u001b[39m \u001b[43m            \u001b[49m\u001b[43mcursor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstr_statement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43meffective_parameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\n\u001b[32m   1969\u001b[39m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1971\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._has_events \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m.engine._has_events:\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\default.py:951\u001b[39m, in \u001b[36mDefaultDialect.do_execute\u001b[39m\u001b[34m(self, cursor, statement, parameters, context)\u001b[39m\n\u001b[32m    950\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mdo_execute\u001b[39m(\u001b[38;5;28mself\u001b[39m, cursor, statement, parameters, context=\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[32m--> \u001b[39m\u001b[32m951\u001b[39m     \u001b[43mcursor\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstatement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:580\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor.execute\u001b[39m\u001b[34m(self, operation, parameters)\u001b[39m\n\u001b[32m    579\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mexecute\u001b[39m(\u001b[38;5;28mself\u001b[39m, operation, parameters=\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[32m--> \u001b[39m\u001b[32m580\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_adapt_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mawait_\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    581\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_prepare_and_execute\u001b[49m\u001b[43m(\u001b[49m\u001b[43moperation\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    582\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\util\\_concurrency_py3k.py:132\u001b[39m, in \u001b[36mawait_only\u001b[39m\u001b[34m(awaitable)\u001b[39m\n\u001b[32m    128\u001b[39m \u001b[38;5;66;03m# returns the control to the driver greenlet passing it\u001b[39;00m\n\u001b[32m    129\u001b[39m \u001b[38;5;66;03m# a coroutine to run. Once the awaitable is done, the driver greenlet\u001b[39;00m\n\u001b[32m    130\u001b[39m \u001b[38;5;66;03m# switches back to this greenlet with the result of awaitable that is\u001b[39;00m\n\u001b[32m    131\u001b[39m \u001b[38;5;66;03m# then returned to the caller (or raised as error)\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m132\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcurrent\u001b[49m\u001b[43m.\u001b[49m\u001b[43mparent\u001b[49m\u001b[43m.\u001b[49m\u001b[43mswitch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mawaitable\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\util\\_concurrency_py3k.py:196\u001b[39m, in \u001b[36mgreenlet_spawn\u001b[39m\u001b[34m(fn, _require_await, *args, **kwargs)\u001b[39m\n\u001b[32m    193\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    194\u001b[39m     \u001b[38;5;66;03m# wait for a coroutine from await_only and then return its\u001b[39;00m\n\u001b[32m    195\u001b[39m     \u001b[38;5;66;03m# result back to it.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m196\u001b[39m     value = \u001b[38;5;28;01mawait\u001b[39;00m result\n\u001b[32m    197\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m:\n\u001b[32m    198\u001b[39m     \u001b[38;5;66;03m# this allows an exception to be raised within\u001b[39;00m\n\u001b[32m    199\u001b[39m     \u001b[38;5;66;03m# the moderated greenlet so that it can continue\u001b[39;00m\n\u001b[32m    200\u001b[39m     \u001b[38;5;66;03m# its expected flow.\u001b[39;00m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:558\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor._prepare_and_execute\u001b[39m\u001b[34m(self, operation, parameters)\u001b[39m\n\u001b[32m    557\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m error:\n\u001b[32m--> \u001b[39m\u001b[32m558\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_handle_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:508\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor._handle_exception\u001b[39m\u001b[34m(self, error)\u001b[39m\n\u001b[32m    507\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_handle_exception\u001b[39m(\u001b[38;5;28mself\u001b[39m, error):\n\u001b[32m--> \u001b[39m\u001b[32m508\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_adapt_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_handle_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:792\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_connection._handle_exception\u001b[39m\u001b[34m(self, error)\u001b[39m\n\u001b[32m    789\u001b[39m         translated_error.pgcode = translated_error.sqlstate = (\n\u001b[32m    790\u001b[39m             \u001b[38;5;28mgetattr\u001b[39m(error, \u001b[33m\"\u001b[39m\u001b[33msqlstate\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m    791\u001b[39m         )\n\u001b[32m--> \u001b[39m\u001b[32m792\u001b[39m         \u001b[38;5;28;01mraise\u001b[39;00m translated_error \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merror\u001b[39;00m\n\u001b[32m    793\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "\u001b[31mProgrammingError\u001b[39m: <class 'asyncpg.exceptions.DuplicateTableError'>: relation \"test_vectorstore\" already exists",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[31mProgrammingError\u001b[39m                          Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m      1\u001b[39m \u001b[38;5;66;03m# 初始化向量存储表\u001b[39;00m\n\u001b[32m      2\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m     \u001b[38;5;28;01mawait\u001b[39;00m pg_engine.ainit_vectorstore_table(\n\u001b[32m      4\u001b[39m         table_name=TABLE_NAME,\n\u001b[32m      5\u001b[39m         vector_size=VECTOR_SIZE,\n\u001b[32m      6\u001b[39m     )\n\u001b[32m      7\u001b[39m     \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33m✓ 向量存储表初始化完成\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m      8\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\langchain_postgres\\v2\\engine.py:307\u001b[39m, in \u001b[36mPGEngine.ainit_vectorstore_table\u001b[39m\u001b[34m(self, table_name, vector_size, schema_name, content_column, embedding_column, metadata_columns, metadata_json_column, id_column, overwrite_existing, store_metadata, hybrid_search_config)\u001b[39m\n\u001b[32m    266\u001b[39m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mainit_vectorstore_table\u001b[39m(\n\u001b[32m    267\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m    268\u001b[39m     table_name: \u001b[38;5;28mstr\u001b[39m,\n\u001b[32m   (...)\u001b[39m\u001b[32m    279\u001b[39m     hybrid_search_config: Optional[HybridSearchConfig] = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m    280\u001b[39m ) -> \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m    281\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m    282\u001b[39m \u001b[33;03m    Create a table for saving of vectors to be used with PGVectorStore.\u001b[39;00m\n\u001b[32m    283\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m    305\u001b[39m \u001b[33;03m            Default: None.\u001b[39;00m\n\u001b[32m    306\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m307\u001b[39m     \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m._run_as_async(\n\u001b[32m    308\u001b[39m         \u001b[38;5;28mself\u001b[39m._ainit_vectorstore_table(\n\u001b[32m    309\u001b[39m             table_name,\n\u001b[32m    310\u001b[39m             vector_size,\n\u001b[32m    311\u001b[39m             schema_name=schema_name,\n\u001b[32m    312\u001b[39m             content_column=content_column,\n\u001b[32m    313\u001b[39m             embedding_column=embedding_column,\n\u001b[32m    314\u001b[39m             metadata_columns=metadata_columns,\n\u001b[32m    315\u001b[39m             metadata_json_column=metadata_json_column,\n\u001b[32m    316\u001b[39m             id_column=id_column,\n\u001b[32m    317\u001b[39m             overwrite_existing=overwrite_existing,\n\u001b[32m    318\u001b[39m             store_metadata=store_metadata,\n\u001b[32m    319\u001b[39m             hybrid_search_config=hybrid_search_config,\n\u001b[32m    320\u001b[39m         )\n\u001b[32m    321\u001b[39m     )\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\langchain_postgres\\v2\\engine.py:121\u001b[39m, in \u001b[36mPGEngine._run_as_async\u001b[39m\u001b[34m(self, coro)\u001b[39m\n\u001b[32m    119\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m coro\n\u001b[32m    120\u001b[39m \u001b[38;5;66;03m# Otherwise, run in the background thread\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m121\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m asyncio.wrap_future(\n\u001b[32m    122\u001b[39m     asyncio.run_coroutine_threadsafe(coro, \u001b[38;5;28mself\u001b[39m._loop)\n\u001b[32m    123\u001b[39m )\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\langchain_postgres\\v2\\engine.py:263\u001b[39m, in \u001b[36mPGEngine._ainit_vectorstore_table\u001b[39m\u001b[34m(self, table_name, vector_size, schema_name, content_column, embedding_column, metadata_columns, metadata_json_column, id_column, overwrite_existing, store_metadata, hybrid_search_config)\u001b[39m\n\u001b[32m    260\u001b[39m query += \u001b[33m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m);\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    262\u001b[39m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m._pool.connect() \u001b[38;5;28;01mas\u001b[39;00m conn:\n\u001b[32m--> \u001b[39m\u001b[32m263\u001b[39m     \u001b[38;5;28;01mawait\u001b[39;00m conn.execute(text(query))\n\u001b[32m    264\u001b[39m     \u001b[38;5;28;01mawait\u001b[39;00m conn.commit()\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\ext\\asyncio\\engine.py:658\u001b[39m, in \u001b[36mAsyncConnection.execute\u001b[39m\u001b[34m(self, statement, parameters, execution_options)\u001b[39m\n\u001b[32m    620\u001b[39m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mexecute\u001b[39m(\n\u001b[32m    621\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m    622\u001b[39m     statement: Executable,\n\u001b[32m   (...)\u001b[39m\u001b[32m    625\u001b[39m     execution_options: Optional[CoreExecuteOptionsParameter] = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m    626\u001b[39m ) -> CursorResult[Any]:\n\u001b[32m    627\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33mr\u001b[39m\u001b[33;03m\"\"\"Executes a SQL statement construct and return a buffered\u001b[39;00m\n\u001b[32m    628\u001b[39m \u001b[33;03m    :class:`_engine.Result`.\u001b[39;00m\n\u001b[32m    629\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m    656\u001b[39m \n\u001b[32m    657\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m658\u001b[39m     result = \u001b[38;5;28;01mawait\u001b[39;00m greenlet_spawn(\n\u001b[32m    659\u001b[39m         \u001b[38;5;28mself\u001b[39m._proxied.execute,\n\u001b[32m    660\u001b[39m         statement,\n\u001b[32m    661\u001b[39m         parameters,\n\u001b[32m    662\u001b[39m         execution_options=execution_options,\n\u001b[32m    663\u001b[39m         _require_await=\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[32m    664\u001b[39m     )\n\u001b[32m    665\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m _ensure_sync_result(result, \u001b[38;5;28mself\u001b[39m.execute)\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\util\\_concurrency_py3k.py:201\u001b[39m, in \u001b[36mgreenlet_spawn\u001b[39m\u001b[34m(fn, _require_await, *args, **kwargs)\u001b[39m\n\u001b[32m    196\u001b[39m     value = \u001b[38;5;28;01mawait\u001b[39;00m result\n\u001b[32m    197\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m:\n\u001b[32m    198\u001b[39m     \u001b[38;5;66;03m# this allows an exception to be raised within\u001b[39;00m\n\u001b[32m    199\u001b[39m     \u001b[38;5;66;03m# the moderated greenlet so that it can continue\u001b[39;00m\n\u001b[32m    200\u001b[39m     \u001b[38;5;66;03m# its expected flow.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m201\u001b[39m     result = \u001b[43mcontext\u001b[49m\u001b[43m.\u001b[49m\u001b[43mthrow\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43msys\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexc_info\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    202\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    203\u001b[39m     result = context.switch(value)\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1419\u001b[39m, in \u001b[36mConnection.execute\u001b[39m\u001b[34m(self, statement, parameters, execution_options)\u001b[39m\n\u001b[32m   1417\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m exc.ObjectNotExecutableError(statement) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merr\u001b[39;00m\n\u001b[32m   1418\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1419\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmeth\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1420\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m   1421\u001b[39m \u001b[43m        \u001b[49m\u001b[43mdistilled_parameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1422\u001b[39m \u001b[43m        \u001b[49m\u001b[43mexecution_options\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mNO_OPTIONS\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1423\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\sql\\elements.py:526\u001b[39m, in \u001b[36mClauseElement._execute_on_connection\u001b[39m\u001b[34m(self, connection, distilled_params, execution_options)\u001b[39m\n\u001b[32m    524\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m TYPE_CHECKING:\n\u001b[32m    525\u001b[39m         \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m, Executable)\n\u001b[32m--> \u001b[39m\u001b[32m526\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mconnection\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_execute_clauseelement\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    527\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdistilled_params\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexecution_options\u001b[49m\n\u001b[32m    528\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    529\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    530\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m exc.ObjectNotExecutableError(\u001b[38;5;28mself\u001b[39m)\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1641\u001b[39m, in \u001b[36mConnection._execute_clauseelement\u001b[39m\u001b[34m(self, elem, distilled_parameters, execution_options)\u001b[39m\n\u001b[32m   1629\u001b[39m compiled_cache: Optional[CompiledCacheType] = execution_options.get(\n\u001b[32m   1630\u001b[39m     \u001b[33m\"\u001b[39m\u001b[33mcompiled_cache\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28mself\u001b[39m.engine._compiled_cache\n\u001b[32m   1631\u001b[39m )\n\u001b[32m   1633\u001b[39m compiled_sql, extracted_params, cache_hit = elem._compile_w_cache(\n\u001b[32m   1634\u001b[39m     dialect=dialect,\n\u001b[32m   1635\u001b[39m     compiled_cache=compiled_cache,\n\u001b[32m   (...)\u001b[39m\u001b[32m   1639\u001b[39m     linting=\u001b[38;5;28mself\u001b[39m.dialect.compiler_linting | compiler.WARN_LINTING,\n\u001b[32m   1640\u001b[39m )\n\u001b[32m-> \u001b[39m\u001b[32m1641\u001b[39m ret = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_execute_context\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1642\u001b[39m \u001b[43m    \u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1643\u001b[39m \u001b[43m    \u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexecution_ctx_cls\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_init_compiled\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1644\u001b[39m \u001b[43m    \u001b[49m\u001b[43mcompiled_sql\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1645\u001b[39m \u001b[43m    \u001b[49m\u001b[43mdistilled_parameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1646\u001b[39m \u001b[43m    \u001b[49m\u001b[43mexecution_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1647\u001b[39m \u001b[43m    \u001b[49m\u001b[43mcompiled_sql\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1648\u001b[39m \u001b[43m    \u001b[49m\u001b[43mdistilled_parameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1649\u001b[39m \u001b[43m    \u001b[49m\u001b[43melem\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1650\u001b[39m \u001b[43m    \u001b[49m\u001b[43mextracted_params\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1651\u001b[39m \u001b[43m    \u001b[49m\u001b[43mcache_hit\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcache_hit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   1652\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1653\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m has_events:\n\u001b[32m   1654\u001b[39m     \u001b[38;5;28mself\u001b[39m.dispatch.after_execute(\n\u001b[32m   1655\u001b[39m         \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   1656\u001b[39m         elem,\n\u001b[32m   (...)\u001b[39m\u001b[32m   1660\u001b[39m         ret,\n\u001b[32m   1661\u001b[39m     )\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1846\u001b[39m, in \u001b[36mConnection._execute_context\u001b[39m\u001b[34m(self, dialect, constructor, statement, parameters, execution_options, *args, **kw)\u001b[39m\n\u001b[32m   1844\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._exec_insertmany_context(dialect, context)\n\u001b[32m   1845\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1846\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_exec_single_context\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1847\u001b[39m \u001b[43m        \u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstatement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\n\u001b[32m   1848\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1986\u001b[39m, in \u001b[36mConnection._exec_single_context\u001b[39m\u001b[34m(self, dialect, context, statement, parameters)\u001b[39m\n\u001b[32m   1983\u001b[39m     result = context._setup_result_proxy()\n\u001b[32m   1985\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[32m-> \u001b[39m\u001b[32m1986\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_handle_dbapi_exception\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1987\u001b[39m \u001b[43m        \u001b[49m\u001b[43me\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstr_statement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43meffective_parameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcursor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\n\u001b[32m   1988\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1990\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:2355\u001b[39m, in \u001b[36mConnection._handle_dbapi_exception\u001b[39m\u001b[34m(self, e, statement, parameters, cursor, context, is_sub_exec)\u001b[39m\n\u001b[32m   2353\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m should_wrap:\n\u001b[32m   2354\u001b[39m     \u001b[38;5;28;01massert\u001b[39;00m sqlalchemy_exception \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m2355\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m sqlalchemy_exception.with_traceback(exc_info[\u001b[32m2\u001b[39m]) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01me\u001b[39;00m\n\u001b[32m   2356\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m   2357\u001b[39m     \u001b[38;5;28;01massert\u001b[39;00m exc_info[\u001b[32m1\u001b[39m] \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\base.py:1967\u001b[39m, in \u001b[36mConnection._exec_single_context\u001b[39m\u001b[34m(self, dialect, context, statement, parameters)\u001b[39m\n\u001b[32m   1965\u001b[39m                 \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[32m   1966\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m evt_handled:\n\u001b[32m-> \u001b[39m\u001b[32m1967\u001b[39m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdo_execute\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1968\u001b[39m \u001b[43m            \u001b[49m\u001b[43mcursor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstr_statement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43meffective_parameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\n\u001b[32m   1969\u001b[39m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1971\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m._has_events \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m.engine._has_events:\n\u001b[32m   1972\u001b[39m     \u001b[38;5;28mself\u001b[39m.dispatch.after_cursor_execute(\n\u001b[32m   1973\u001b[39m         \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   1974\u001b[39m         cursor,\n\u001b[32m   (...)\u001b[39m\u001b[32m   1978\u001b[39m         context.executemany,\n\u001b[32m   1979\u001b[39m     )\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\engine\\default.py:951\u001b[39m, in \u001b[36mDefaultDialect.do_execute\u001b[39m\u001b[34m(self, cursor, statement, parameters, context)\u001b[39m\n\u001b[32m    950\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mdo_execute\u001b[39m(\u001b[38;5;28mself\u001b[39m, cursor, statement, parameters, context=\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[32m--> \u001b[39m\u001b[32m951\u001b[39m     \u001b[43mcursor\u001b[49m\u001b[43m.\u001b[49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstatement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:580\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor.execute\u001b[39m\u001b[34m(self, operation, parameters)\u001b[39m\n\u001b[32m    579\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mexecute\u001b[39m(\u001b[38;5;28mself\u001b[39m, operation, parameters=\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[32m--> \u001b[39m\u001b[32m580\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_adapt_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mawait_\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    581\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_prepare_and_execute\u001b[49m\u001b[43m(\u001b[49m\u001b[43moperation\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    582\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\util\\_concurrency_py3k.py:132\u001b[39m, in \u001b[36mawait_only\u001b[39m\u001b[34m(awaitable)\u001b[39m\n\u001b[32m    123\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m exc.MissingGreenlet(\n\u001b[32m    124\u001b[39m         \u001b[33m\"\u001b[39m\u001b[33mgreenlet_spawn has not been called; can\u001b[39m\u001b[33m'\u001b[39m\u001b[33mt call await_only() \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    125\u001b[39m         \u001b[33m\"\u001b[39m\u001b[33mhere. Was IO attempted in an unexpected place?\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    126\u001b[39m     )\n\u001b[32m    128\u001b[39m \u001b[38;5;66;03m# returns the control to the driver greenlet passing it\u001b[39;00m\n\u001b[32m    129\u001b[39m \u001b[38;5;66;03m# a coroutine to run. Once the awaitable is done, the driver greenlet\u001b[39;00m\n\u001b[32m    130\u001b[39m \u001b[38;5;66;03m# switches back to this greenlet with the result of awaitable that is\u001b[39;00m\n\u001b[32m    131\u001b[39m \u001b[38;5;66;03m# then returned to the caller (or raised as error)\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m132\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcurrent\u001b[49m\u001b[43m.\u001b[49m\u001b[43mparent\u001b[49m\u001b[43m.\u001b[49m\u001b[43mswitch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mawaitable\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\util\\_concurrency_py3k.py:196\u001b[39m, in \u001b[36mgreenlet_spawn\u001b[39m\u001b[34m(fn, _require_await, *args, **kwargs)\u001b[39m\n\u001b[32m    192\u001b[39m switch_occurred = \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[32m    193\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    194\u001b[39m     \u001b[38;5;66;03m# wait for a coroutine from await_only and then return its\u001b[39;00m\n\u001b[32m    195\u001b[39m     \u001b[38;5;66;03m# result back to it.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m196\u001b[39m     value = \u001b[38;5;28;01mawait\u001b[39;00m result\n\u001b[32m    197\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m:\n\u001b[32m    198\u001b[39m     \u001b[38;5;66;03m# this allows an exception to be raised within\u001b[39;00m\n\u001b[32m    199\u001b[39m     \u001b[38;5;66;03m# the moderated greenlet so that it can continue\u001b[39;00m\n\u001b[32m    200\u001b[39m     \u001b[38;5;66;03m# its expected flow.\u001b[39;00m\n\u001b[32m    201\u001b[39m     result = context.throw(*sys.exc_info())\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:558\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor._prepare_and_execute\u001b[39m\u001b[34m(self, operation, parameters)\u001b[39m\n\u001b[32m    555\u001b[39m             \u001b[38;5;28mself\u001b[39m.rowcount = -\u001b[32m1\u001b[39m\n\u001b[32m    557\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m error:\n\u001b[32m--> \u001b[39m\u001b[32m558\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_handle_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:508\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_cursor._handle_exception\u001b[39m\u001b[34m(self, error)\u001b[39m\n\u001b[32m    507\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_handle_exception\u001b[39m(\u001b[38;5;28mself\u001b[39m, error):\n\u001b[32m--> \u001b[39m\u001b[32m508\u001b[39m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_adapt_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_handle_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32md:\\project\\streamlit\\generic\\.venv\\Lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\asyncpg.py:792\u001b[39m, in \u001b[36mAsyncAdapt_asyncpg_connection._handle_exception\u001b[39m\u001b[34m(self, error)\u001b[39m\n\u001b[32m    786\u001b[39m         translated_error = exception_mapping[super_](\n\u001b[32m    787\u001b[39m             \u001b[33m\"\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[33m: \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[33m\"\u001b[39m % (\u001b[38;5;28mtype\u001b[39m(error), error)\n\u001b[32m    788\u001b[39m         )\n\u001b[32m    789\u001b[39m         translated_error.pgcode = translated_error.sqlstate = (\n\u001b[32m    790\u001b[39m             \u001b[38;5;28mgetattr\u001b[39m(error, \u001b[33m\"\u001b[39m\u001b[33msqlstate\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m    791\u001b[39m         )\n\u001b[32m--> \u001b[39m\u001b[32m792\u001b[39m         \u001b[38;5;28;01mraise\u001b[39;00m translated_error \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merror\u001b[39;00m\n\u001b[32m    793\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    794\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m error\n",
      "\u001b[31mProgrammingError\u001b[39m: (sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.DuplicateTableError'>: relation \"test_vectorstore\" already exists\n[SQL: CREATE TABLE \"public\".\"test_vectorstore\"(\n            \"langchain_id\" UUID PRIMARY KEY,\n            \"content\" TEXT NOT NULL,\n            \"embedding\" vector(1024) NOT NULL\n            ,\n\"langchain_metadata\" JSON\n);]\n(Background on this error at: https://sqlalche.me/e/20/f405)"
     ]
    }
   ],
   "source": [
    "# 初始化向量存储表\n",
    "try:\n",
    "    await pg_engine.ainit_vectorstore_table(\n",
    "        table_name=TABLE_NAME,\n",
    "        vector_size=VECTOR_SIZE,\n",
    "    )\n",
    "    print(\"✓ 向量存储表初始化完成\")\n",
    "except Exception as e:\n",
    "    print(f\"❌ 初始化表失败: {e}\")\n",
    "    raise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "embeddings",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.09829633682966232, 0.03433719649910927, -0.06495697796344757, -0.023008856922388077, -0.041752465069293976, -0.04022636637091637, 0.037056781351566315, 0.10463551431894302, -0.03048282116651535, 0.004734815564006567, 0.0029763795901089907, 0.01569141447544098, 0.009225064888596535, -0.013324006460607052, 0.014615319669246674, -0.012423999607563019, 0.04151768237352371, -0.010007678531110287, -0.03279153257608414, -0.0565047413110733, -0.0707874521613121, -0.015251193195581436, 0.04875686392188072, 0.04437422379851341, 0.011592471972107887, 0.09430500864982605, -0.04386552423238754, -0.026941493153572083, 0.039404623210430145, -0.040108975023031235, 0.06120042875409126, -0.032165441662073135, 0.04820903390645981, -0.055017776787281036, -0.009381587617099285, -0.01228704210370779, 0.00012358272215351462, -0.01955557055771351, -0.11042685806751251, -0.0007110783481039107, 0.05431342124938965, -0.029993688687682152, 0.008775060996413231, -0.04680032655596733, 0.0011237850412726402, -0.03281109780073166, 0.01680663973093033, -0.06836134940385818, -0.02782193385064602, -0.014703363180160522, -0.0268240999430418, 0.005038078874349594, 0.03376980125904083, -0.02966107614338398, 0.021130582317709923, -0.016239244490861893, 0.0028100740164518356, -0.022578418254852295, -0.05634821951389313, 0.021737108007073402, -0.06836134940385818, 0.008065816946327686, -0.010222897864878178, 0.01650337688624859, 0.02926976978778839, 0.07900489866733551, 0.03545242175459862, 0.00024013414804358035, -0.0495394766330719, -0.049382954835891724, -0.038993749767541885, -0.007630487903952599, -0.011201165616512299, 0.01136747095733881, -0.07579617947340012, 0.008197883144021034, 0.007244072388857603, -0.01989796571433544, 0.017667515203356743, -0.02987629547715187, 0.08671364933252335, 0.028506720438599586, 0.021267540752887726, 0.010418551042675972, -0.008422885090112686, -0.0003405594325158745, -0.009078324772417545, 0.001033295295201242, -0.0038054613396525383, -0.003394588828086853, -0.07466138899326324, -0.04883512482047081, 0.03691982477903366, -0.0324002280831337, -0.051848188042640686, 0.020308837294578552, -0.037252433598041534, 0.03200891986489296, 0.012688132002949715, 0.02529800310730934, 0.022461026906967163, 0.03488502651453018, 0.005737540312111378, -0.045313358306884766, 0.047348156571388245, -0.030130645260214806, 0.02917194366455078, 0.024084951728582382, 0.025845833122730255, -0.02467191219329834, 0.023889297619462013, 0.019594702869653702, 0.03993288800120354, 0.010350072756409645, 0.00799733866006136, 0.019604485481977463, -0.01996644400060177, -0.021737108007073402, -0.03326110169291496, 0.012531609274446964, 0.029719773679971695, -0.01988818310201168, 0.043787263333797455, -0.05830475687980652, 0.010389203205704689, -0.04523509740829468, 0.02946542389690876, 0.037585046142339706, 0.01621967926621437, -0.03719373792409897, 0.02662844769656658, 0.0466829352080822, 0.006652220617979765, -0.025356698781251907, -0.07297877222299576, -0.03357414901256561, 0.019721876829862595, 0.01071203127503395, 0.00912234652787447, -0.044491615146398544, 0.06390044838190079, -0.016043590381741524, -0.019809920340776443, 0.00020864616089966148, 0.022265372797846794, -0.05646561086177826, 0.026452358812093735, 0.001825692132115364, 0.02568930946290493, 0.016239244490861893, -0.020250141620635986, 0.0002320328785572201, 0.018322953954339027, -0.012854437343776226, 0.04515683650970459, 0.003932636231184006, 0.007992447353899479, 0.006143521051853895, 0.052669934928417206, 0.08209622651338577, -0.0007080212235450745, -0.002339282538741827, -0.020856667309999466, -0.007914185523986816, -0.030032819136977196, 0.05098731443285942, 0.013754444196820259, 0.03592199087142944, -0.031148044392466545, -0.03815244138240814, 0.00767451012507081, -0.020025139674544334, 0.008403319865465164, -0.015574022196233273, 0.021287105977535248, 0.040617674589157104, 0.09774851053953171, 0.010985946282744408, 0.017462078481912613, -0.05716996639966965, -0.0352567695081234, 0.05423516035079956, -0.03208718076348305, -0.020426230505108833, -0.01653272472321987, -0.0014453905168920755, 0.005238623358309269, 0.00794842466711998, -0.0015297661302611232, 0.002998390467837453, -0.0336524099111557, -0.05345254763960838, 0.005419603083282709, -0.03707634657621384, -0.0031475762370973825, 0.016239244490861893, 0.016855552792549133, -0.015759892761707306, 0.0005707580712623894, -0.029621945694088936, -0.05658300593495369, 0.002956814132630825, 0.03805461525917053, 0.006495697423815727, -0.0035804598592221737, -0.022265372797846794, -0.06073085963726044, -0.03564807400107384, 0.01639576628804207, -0.06675698608160019, -0.04586118832230568, 0.016160981729626656, -0.019222959876060486, -0.01116203423589468, -0.007796793710440397, -0.016180546954274178, 0.018675129860639572, -0.01054572593420744, 0.025141479447484016, -0.03993288800120354, -0.02118927799165249, 0.028467589989304543, 0.040617674589157104, 0.04488292336463928, 0.02426103875041008, -1.541918027214706e-05, 0.021678412333130836, 0.055291689932346344, 0.04108724370598793, -0.037369824945926666, -0.018117517232894897, -0.00558101711794734, 0.018283823505043983, -0.024221908301115036, 0.059596069157123566, 0.00048332539154216647, -0.004243236035108566, 0.004600303713232279, 0.029798034578561783, -0.004959817044436932, 0.007141354028135538, -0.008652777411043644, 0.033808931708335876, -0.00718537624925375, -0.04578292742371559, -0.02060231752693653, 0.03026760369539261, 0.006383196916431189, -0.017872951924800873, -0.0032062723767012358, 0.0023490653838962317, -0.020132750272750854, -0.01519249752163887, 0.04005027934908867, -0.009342456236481667, 0.020054487511515617, 0.023595817387104034, -0.025532787665724754, 0.02496539242565632, -0.0422220341861248, 0.004023125860840082, -0.015290324576199055, 0.033476319164037704, 0.04089159145951271, -0.005414711777120829, -0.03813287615776062, -0.053569938987493515, 0.009083216078579426, 0.008129404857754707, -0.015613152645528316, 0.001549331471323967, -0.04496118426322937, 0.01105442550033331, -0.013685964979231358, 0.002550833160057664, -0.007082658354192972, -0.03701765090227127, -0.00851582083851099, 0.02803715318441391, 0.020034922286868095, -0.017060989513993263, 0.0015028637135401368, 0.016855552792549133, -0.02040666528046131, 0.0020372425206005573, -0.03915027529001236, 0.0065495022572577, -0.031363263726234436, 0.0179414302110672, 0.001352455117739737, 0.0009201830835081637, 0.009675067849457264, 0.05493951588869095, -0.00861853826791048, -0.027293669059872627, -0.006114173214882612, 0.02516104467213154, -0.18892306089401245, -0.005248406436294317, 0.0015566684305667877, -0.010144636034965515, 0.02109145186841488, 0.009631045162677765, -0.010213115252554417, -0.04515683650970459, 0.007767445407807827, 0.05372646078467369, 0.016444679349660873, -0.04496118426322937, -0.060809120535850525, 0.002770943334326148, -0.02026970684528351, 0.0023564023431390524, -0.010222897864878178, -0.03351545333862305, -0.003208718029782176, -0.02314581349492073, -0.019712094217538834, -0.025121914222836494, 0.0978267714381218, 0.021228408440947533, 0.012013127095997334, -0.0051750363782048225, 0.0670309066772461, -0.028115414083003998, -0.023087117820978165, 0.007239181082695723, 0.00860875565558672, -0.022695811465382576, -0.013999010436236858, 0.045509014278650284, 0.009053867310285568, 0.05654387176036835, 0.05059600621461868, 0.004602749366313219, -0.04085246101021767, -0.02447625808417797, 0.006143521051853895, 0.030521951615810394, -0.016552289947867393, 0.014204447157680988, 0.019418613985180855, -0.009234847500920296, 0.055526476353406906, -0.013187048956751823, -0.04421770200133324, -0.03596112132072449, -0.01622946187853813, 0.0009097889414988458, 0.008877779357135296, -0.028056718409061432, -0.03979593142867088, -0.022656679153442383, -0.025924094021320343, 0.035511117428541183, -0.042339425534009933, 0.002704910235479474, 0.007513096090406179, -0.041126374155282974, 0.05043948441743851, 0.011934866197407246, -0.001868491293862462, -0.01958492025732994, 0.013656617142260075, -0.020837102085351944, -0.013999010436236858, -0.01704142428934574, 0.013666399754583836, 0.01793164759874344, 0.006466349586844444, -0.023106683045625687, 0.017305554822087288, 0.019428396597504616, 0.009479413740336895, -0.010614204220473766, -0.012120736762881279, -0.08921801298856735, 0.02995455637574196, 0.029132813215255737, -0.023713208734989166, 0.003961984068155289, -0.01997622661292553, -0.015055540017783642, -0.015652284026145935, 0.006290261168032885, 0.02813497930765152, 0.26514968276023865, -0.004649217240512371, 0.0007000728510320187, -0.03353501856327057, 0.030306734144687653, -0.022187111899256706, -0.04852207750082016, -0.030541518703103065, -0.036137208342552185, -0.04273073375225067, 0.018225127831101418, -0.01600445993244648, -0.006280478555709124, 0.025728439912199974, 0.018195779994130135, 0.029191508889198303, -0.010173983871936798, -0.011964214034378529, 0.09109628945589066, -0.004199214279651642, 0.03932636231184006, -0.013480529189109802, 0.03641112521290779, 0.009973439387977123, -0.03652851656079292, -0.02641322836279869, 0.0034459480084478855, -0.0009293543407693505, -0.05513516813516617, 0.02336103282868862, -0.021071886643767357, -0.008872888050973415, 0.03255674988031387, 0.001682620495557785, 0.022480592131614685, 0.013187048956751823, 0.03958071023225784, -0.016650116071105003, -0.021580586209893227, 0.014693580567836761, -0.010985946282744408, -0.031852398067712784, -0.02670670859515667, 0.03353501856327057, -0.013979445211589336, -0.011807691305875778, -0.007327225059270859, -0.03568720445036888, 0.019907748326659203, -0.03148065507411957, 0.02692192792892456, 0.011582689359784126, 0.01578924059867859, 0.03484589606523514, 0.008290818892419338, 0.041830725967884064, -0.045430753380060196, -0.018919697031378746, -0.039404623210430145, 0.040617674589157104, -0.005006284918636084, 0.02336103282868862, -0.06288304924964905, 0.019614268094301224, -0.005771779455244541, 0.02995455637574196, -0.059165630489587784, -0.027293669059872627, 0.023497989401221275, 0.016160981729626656, 0.03408284857869148, -0.015221845358610153, 0.02670670859515667, 0.03271327167749405, -0.003781004576012492, 0.0024896913673728704, -0.0068674394860863686, 0.05791344866156578, 0.00036104192258790135, 0.06663959473371506, -0.017256641760468483, 0.023576252162456512, -0.024339299649000168, -0.00478862039744854, 0.0001491094008088112, -0.02242189645767212, 0.0008437559008598328, 0.029895860701799393, -0.032380662858486176, -0.03375023603439331, -0.03478720039129257, -0.007473965175449848, -0.019751224666833878, -0.028898028656840324, -0.015290324576199055, -0.015075105242431164, -0.002317271661013365, -0.007537552621215582, -0.021247973665595055, -0.008789734914898872, -0.03529589995741844, -0.018097952008247375, -0.0007422605995088816, -0.015084887854754925, 0.0233414676040411, -0.026256704702973366, 0.015847936272621155, -0.005003839265555143, -0.007650053594261408, 0.014253360219299793, -0.030658910050988197, 0.013059874065220356, -0.027137145400047302, -0.010897901840507984, 0.023517556488513947, -0.0011953208595514297, 0.015329455025494099, 0.01969252899289131, 0.03556981310248375, 0.07180485129356384, 0.013901184312999249, -0.01534902025014162, -0.003944864496588707, -0.0010375751880928874, -0.013969662599265575, -0.020915362983942032, -0.007601140066981316, 0.006642437539994717, 0.0007410377729684114, 0.0201718807220459, 0.007796793710440397, -0.0460568442940712, -0.01752077415585518, -0.004028017167001963, -0.0011372362496331334, 0.025141479447484016, 0.07368312031030655, 0.0540003776550293, -0.044922053813934326, 0.03243935853242874, -0.01744251325726509, -0.050909049808979034, -0.009616371244192123, 0.018088169395923615, -0.02731323428452015, 0.010115288197994232, -0.0030864346772432327, 0.015681631863117218, 0.007165811024606228, 0.017892517149448395, 0.020974060520529747, -0.01764794997870922, -0.0056788441725075245, -0.05736561864614487, 0.01701207458972931, -0.04241768643260002, -0.007126680109649897, -0.0036342644598335028, 0.01752077415585518, -0.042574211955070496, -0.026237139478325844, -0.041322026401758194, 0.035119809210300446, 0.0432003028690815, -0.012834872119128704, 0.00866256095468998, 0.018694695085287094, 0.010966381058096886, 0.02852628566324711, -0.006383196916431189, 0.010457681491971016, 0.0015297661302611232, -0.06491784751415253, 0.0711396262049675, -0.002900563646107912, -0.05180905759334564, -0.01733490452170372, -0.01763816736638546, -0.02435886673629284, -0.002932357368990779, 0.029093680903315544, -0.02547409199178219, -0.01116203423589468, 0.052669934928417206, -0.017197946086525917, 0.07673531770706177, 0.01533923763781786, -0.020113183185458183, 0.03558937832713127, -0.03764374181628227, -0.01997622661292553, 0.09540066868066788, -0.046839457005262375, -0.023067552596330643, 0.03956114500761032, -0.005321776494383812, 0.00913212914019823, 0.010262028314173222, 0.004754381254315376, -0.01946752704679966, 0.013969662599265575, 0.0032478487119078636, 0.015945764258503914, -0.0070386361330747604, -0.02314581349492073, -0.016385983675718307, -0.033593714237213135, -0.02160015143454075, -0.011944648809731007, 0.019320787861943245, -0.014272925443947315, 0.001880719675682485, -0.009919634088873863, -0.008985389024019241, 0.00942560937255621, -0.029230639338493347, 0.02966107614338398, 0.02559148333966732, -0.026843665167689323, -0.042769864201545715, 0.00785548985004425, -0.016141416504979134, 0.02537626400589943, -0.05419602990150452, -0.0021032756194472313, 0.02835019864141941, -0.027352364733815193, -0.01823491044342518, 0.025024088099598885, 0.0034899699967354536, -0.002770943334326148, 0.008378863334655762, -0.029837165027856827, -0.05036121979355812, 0.055213429033756256, -0.017178380861878395, 0.004957371391355991, 0.04597858339548111, -0.04304377734661102, -0.023302337154746056, 0.0036758407950401306, -0.005517429672181606, 0.03893505409359932, 0.038876358419656754, -0.008075599558651447, 0.036645907908678055, -0.031852398067712784, -0.014859886839985847, 0.031148044392466545, 0.01805882155895233, -0.01793164759874344, -0.00979246012866497, 0.008794626221060753, -0.04003071412444115, -0.01612185128033161, 0.02926976978778839, -0.017491426318883896, -0.0011029968736693263, -0.03979593142867088, 0.022754507139325142, -0.004808185622096062, 0.03619590401649475, -0.026882797479629517, -0.006314718164503574, -0.001715637044981122, -0.06973092257976532, 0.05576125904917717, -0.015652284026145935, -0.018684912472963333, -0.018205562606453896, -0.05086991935968399, -0.004592966753989458, -0.016376201063394547, -0.031148044392466545, 0.05740474909543991, 0.016982726752758026, -0.02496539242565632, 0.028467589989304543, 0.007146245799958706, 0.0004414432914927602, -0.0009348570602014661, -0.020856667309999466, -0.04269160330295563, 0.01826425828039646, 0.010565291158854961, -0.02169797755777836, 0.01640554890036583, -0.003560894401744008, 0.021150147542357445, -0.03120674006640911, 0.026354532688856125, -0.0037565480452030897, -0.009753328748047352, 0.03357414901256561, -0.019937096163630486, -0.03016977570950985, 0.008559842593967915, 0.0011140023125335574, -0.021228408440947533, 0.04140029102563858, -0.0028761071152985096, 0.010663118213415146, -0.027763238176703453, -0.02977846935391426, 0.009518545120954514, 0.014008793979883194, 0.004394867457449436, -0.01864578202366829, -0.00794842466711998, 0.010203332640230656, 0.01376422680914402, -0.09446153044700623, -0.012737045995891094, -0.00011777425970649347, 0.012512044049799442, -0.014155534096062183, 0.048678599298000336, -0.004020680207759142, -0.02488712966442108, 0.024417562410235405, 0.02375233918428421, -0.0039595384150743484, -0.03271327167749405, -0.004365519620478153, -0.054782990366220474, -0.006891896016895771, 0.03854374587535858, 0.021991457790136337, 0.005771779455244541, -0.05118296667933464, 0.0026511054020375013, -0.010007678531110287, -0.0311089139431715, -0.020719710737466812, 0.03580459952354431, 0.045313358306884766, 0.020621882751584053, 0.0017938984092324972, 0.019751224666833878, -0.006035911850631237, 0.02672627381980419, -0.0004860767803620547, 0.06178738921880722, -0.05270906537771225, 0.01340226735919714, -0.04726989567279816, 0.013695747591555119, 0.030228471383452415, 0.007640270981937647, 0.012922916561365128, 0.007332116365432739, 0.0031059999018907547, -0.01887078396975994, -0.028408894315361977, 0.01600445993244648, 0.014409882947802544, 0.028995854780077934, 0.06339174509048462, 0.04636988788843155, 0.006921243853867054, 0.00845712423324585, -0.009753328748047352, -0.01833273656666279, -0.004316606093198061, -0.014155534096062183, -0.012874002568423748, -0.004715250339359045, -0.019105568528175354, 0.016072938218712807, -0.007356573361903429, 0.012267476879060268, 0.04116550460457802, 0.01578924059867859, 0.0037858961150050163, 0.006603307090699673, 0.038074180483818054, -0.03691982477903366, -0.00279050855897367, 0.012198998592793941, -0.005625039339065552, 0.015926199033856392, -0.04691771790385246, 0.043082911521196365, -0.0024896913673728704, 0.038993749767541885, 0.01866534724831581, -0.002646214095875621, 0.0068772220984101295, -0.045626405626535416, 0.013529442250728607, -0.0328502282500267, 0.005145688075572252, -0.002077596029266715, 0.023087117820978165, -0.18313170969486237, 0.0010864885989576578, -0.04625249654054642, -0.003397034713998437, -0.00560547411441803, -0.007151137106120586, 0.04523509740829468, -0.029602380469441414, 0.001450281823053956, -0.03709591180086136, -0.05544821545481682, 0.008775060996413231, 0.006275587249547243, -0.003140239277854562, 0.01876317523419857, 0.03312414512038231, 0.027958890423178673, 0.015026192180812359, -0.03770243749022484, 0.024906694889068604, 0.013500094413757324, 0.006691351067274809, 0.005468516610562801, 0.011846821755170822, -0.03261544555425644, -0.011435949243605137, 0.011709864251315594, 0.01504575740545988, -0.03089369460940361, 0.020015357062220573, 0.03609807789325714, -0.015417499467730522, 0.014028359204530716, 0.02660888247191906, 0.007439726032316685, -0.01085877139121294, 0.007684292737394571, -0.06378305703401566, 0.021639281883835793, 0.0026535510551184416, -0.02995455637574196, 0.034317631274461746, -0.03993288800120354, -0.01682620495557785, 0.06476132571697235, -0.012551174499094486, -0.0003133513673674315, -0.007987556047737598, -0.05012643709778786, 0.006378305610269308, -0.015388150699436665, 0.01998600922524929, 0.001583570847287774, -0.00906364992260933, -0.023830601945519447, 0.03283066302537918, -0.021971892565488815, -0.012688132002949715, -0.008731039240956306, 0.019526222720742226, -0.014282708056271076, 0.009298434481024742, -0.02864367887377739, -0.01988818310201168, -0.05568299815058708, 0.02885889820754528, -0.05756127089262009, 0.060496073216199875, 0.002497028326615691, 0.01640554890036583, -0.029895860701799393, 0.009166368283331394, 0.02680453471839428, -0.03138282895088196, 0.006569067481905222, 0.009538110345602036, 0.00040750965126790106, 0.011641385965049267, 0.001494303927756846, -0.0479351170361042, 0.0009293543407693505, -0.012981612235307693, -0.02028927206993103, 0.052435148507356644, 0.030052384361624718, 0.041556812822818756, 0.01248269621282816, -0.015290324576199055, -0.0473090261220932, -0.0074005951173603535, -0.03466980904340744, 0.003132902318611741, 0.006935918238013983, -0.0009379141847603023, -0.002912792144343257, 0.035726334899663925, -0.023321902379393578, -0.003042412456125021, 0.0019051763229072094, -0.00913212914019823, -0.029113246127963066, 0.0032038267236202955, 0.008716365322470665, 0.02028927206993103, -0.011455514468252659, 0.048795994371175766, 0.005116340238600969, 0.005488081835210323, 0.014899017289280891, 0.02181537076830864, -0.04574379697442055, -0.010575073771178722, 0.012208781205117702, -0.011504428461194038, -0.07759619504213333, 0.0214240625500679, -0.0018281377851963043, 0.011885952204465866, 0.0018611543346196413, -0.005292428191751242, 0.005898954346776009, -0.020661013200879097, 0.011641385965049267, -0.014096837490797043, 0.02641322836279869, -0.0025214850902557373, 0.015681631863117218, 0.003568231360986829, -0.037663307040929794, -0.020308837294578552, 0.023889297619462013, -0.021267540752887726, 0.031226305291056633, 0.019751224666833878, 0.002495805500075221, -0.005370689556002617, -0.021541455760598183, 0.035941556096076965, -0.015417499467730522, 0.0073810298927128315, -0.0261980090290308, -0.03161761164665222, -0.011543558910489082, -0.0020714818965643644, 0.0022267817985266447, 0.0127859590575099, 0.00978756882250309, 0.009993004612624645, -0.014918582513928413, 0.00993430893868208, 0.03465024381875992, -0.0255719181150198, 0.004446226637810469, 0.0033261103089898825, -0.024691477417945862, 0.00624623941257596, 0.012541391886770725, 0.011475080624222755, -0.014360969886183739, 0.04648728296160698, -0.016904465854167938, -0.01101529411971569, -0.026941493153572083, 0.008114730939269066, -0.02375233918428421, 0.06045694276690483, 0.003098662942647934, -0.016376201063394547, -0.034708939492702484, 0.017872951924800873, 0.038895923644304276, -0.022363198921084404, -0.016777291893959045, 0.0038543748669326305, 0.013656617142260075, 0.002736703958362341, -0.01406748965382576, 0.030561083927750587, 0.03586329519748688, 0.01259030494838953, 0.02140449732542038, 0.013989227823913097, 0.03783939406275749, -0.004624760709702969, 0.0005325445090420544, 0.05583951994776726, -0.02050449140369892, 0.009352238848805428, 0.0024750172160565853, -0.010222897864878178, 0.016356635838747025, 0.009748437441885471, -0.02253928780555725, 0.009176150895655155, 0.06808742880821228, 0.035217639058828354, -0.005507647059857845, -0.012570739723742008, -0.0027440409176051617, 0.032674141228199005, -0.0003937527653761208, -0.004614978097379208, -0.0065446109510958195, -0.028487155213952065, -0.03680242970585823, -0.01812729984521866, 0.016963161528110504, 0.0004701799189206213, -0.025434959679841995, 0.023811036720871925, 0.0204849261790514, -0.02193276211619377, 0.0014478361699730158, 0.034611109644174576, 0.026158878579735756, 0.005131014157086611, -0.0004475574824027717, 0.05282645672559738, 0.010506595484912395, -0.0004240178968757391, -0.004920686595141888, 0.012864219956099987, 0.013871836476027966, -0.022695811465382576, -0.014468579553067684, -0.008657669648528099, -0.0239675585180521, 0.007014179602265358, 0.010672900825738907, -0.019193612039089203, -0.006378305610269308, 0.00608971668407321, -0.01330444123595953, 0.01621967926621437, 0.02099362574517727, 0.03189152851700783, 0.05008730664849281, 0.015437064692378044, -0.016170764341950417, -0.021052321419119835, 0.007938642054796219, 0.005238623358309269, -0.006304935552179813, 0.022715376690030098]\n",
      "[[-0.050539933145046234, 0.027052080258727074, -0.0674399733543396, -0.028633955866098404, -0.04697570577263832, -0.05142097920179367, 0.019102653488516808, 0.09651445597410202, -0.029174596071243286, 0.008640246465802193, -0.010942976921796799, 0.025490228086709976, -0.0060822125524282455, -0.04809703677892685, 0.01114321406930685, -0.0213052649050951, 0.041288964450359344, -0.03886609151959419, 0.023307640105485916, -0.03440079465508461, -0.04961884021759033, -0.0022176296915858984, -0.0292146448045969, 0.03400031849741936, 0.07376747578382492, 0.041969768702983856, -0.004750633612275124, -0.06403593719005585, -0.027652792632579803, -0.04969893768429756, 0.040988605469465256, 0.035562172532081604, -0.011683855205774307, -0.056346818804740906, -0.01806141808629036, 0.0059620700776577, 0.0040047490037977695, 0.014226870611310005, -0.10572537779808044, 0.0033464685548096895, -0.0008128389017656446, 0.06323498487472534, 0.025390109047293663, -0.009406154043972492, -0.0069031864404678345, -0.040908511728048325, -0.012584923766553402, -0.05846933647990227, -0.020374160259962082, -0.025870678946375847, -0.010502454824745655, -0.0237882100045681, 0.04229015111923218, -0.06623855233192444, 0.03438077121973038, 0.023367710411548615, -0.03582248091697693, -0.06900182366371155, -0.048817891627550125, 0.036162883043289185, -0.015678592026233673, -0.009726534597575665, -0.011493629775941372, -0.032698776572942734, -0.0019185250857844949, 0.07753194123506546, -0.03199794515967369, -0.006297467742115259, 0.0005021580145694315, 0.034961458295583725, 0.0024992136750370264, 0.010312228463590145, -0.01641947031021118, -0.013455957174301147, -0.049178317189216614, 0.005246221087872982, 0.06179327890276909, -0.03313929960131645, 0.00998684298247099, 0.02392837591469288, 0.14080697298049927, 0.009926771745085716, 0.020664505660533905, -0.025650417432188988, -0.009951801039278507, 0.05778852850198746, -0.009946795180439949, 0.04381195455789566, 0.019132688641548157, -0.004720597993582487, -0.04981907829642296, -0.05110059678554535, 0.03674357384443283, -0.035341911017894745, -0.0012727592838928103, 0.010602572932839394, 0.04637499526143074, 0.048297274857759476, 0.0009148348472081125, -0.01178397424519062, 0.005286268889904022, 0.07036343961954117, 0.021185122430324554, -0.06415607780218124, 0.0013340819859877229, 0.03824535384774208, -0.014126752503216267, 0.02400847151875496, -0.01114321406930685, -0.03400031849741936, 0.06255418062210083, 0.027272341772913933, -0.016379423439502716, -0.000986795173957944, -0.03369996324181557, -0.04080839455127716, 0.008299842476844788, -0.03191785141825676, -0.03922651708126068, 0.0003285145794507116, 0.0049909185618162155, 0.04405223950743675, 0.042930908501148224, -0.057708434760570526, -0.04601456597447395, -0.03612283617258072, 0.0273123886436224, 0.028954336419701576, -0.0005465856520459056, 0.004422744736075401, 0.060631901025772095, 0.021125052124261856, -0.021585596725344658, -0.005421428941190243, -0.037985045462846756, -0.055425725877285004, 0.04018765687942505, -0.004342649597674608, -0.029995569959282875, -0.07064377516508102, 0.052582357078790665, 0.0445728562772274, 0.011283380910754204, 0.00041079966467805207, 0.030596282333135605, -0.07757198810577393, 0.027452554553747177, 0.033239416778087616, -0.006487693637609482, -0.02687186561524868, 0.01689002849161625, -0.024969611316919327, 0.020414208993315697, 0.031116900965571404, 0.007078393828123808, 0.01185405720025301, -0.014437120407819748, 0.03968706354498863, -0.019382985308766365, 0.017220420762896538, 0.05734800547361374, -0.014256906695663929, -0.013866443186998367, -0.015538426116108894, -0.015368224121630192, 0.016839969903230667, -0.028173409402370453, -0.012124378234148026, -0.03440079465508461, -0.022246381267905235, 0.013135576620697975, -0.06980277597904205, 0.03079652041196823, -0.02522991970181465, 0.008054551668465137, 0.03658338263630867, 0.01795128732919693, -0.0026606551837176085, 0.0387459471821785, -0.07965446263551712, -0.0495387464761734, 0.007363732438534498, -0.016649743542075157, -0.022326476871967316, -0.026851842179894447, -0.024929562583565712, -0.003258864628151059, 0.001750826253555715, -0.011613772250711918, 0.05718781799077988, -0.024969611316919327, -0.004980906844139099, -0.024448992684483528, 0.008800435811281204, 0.016499565914273262, -0.006637871731072664, 0.033920224756002426, -0.06159304082393646, -0.049578793346881866, 0.037824854254722595, -0.04809703677892685, 0.01806141808629036, -0.018071429803967476, -0.009971825405955315, -0.03253858536481857, -0.03087661601603031, -0.05466482415795326, -0.04801694303750992, 0.003601771080866456, 0.0039621987380087376, -0.010792798362672329, -0.03544202819466591, -0.008159676566720009, -0.006237396504729986, -0.024889515712857246, 0.012434746138751507, 0.0036242979113012552, -0.03514167293906212, -0.004878284875303507, -0.02364804409444332, 0.032318323850631714, 0.004587940871715546, 0.03634309768676758, 0.05382382869720459, 0.025169847533106804, 0.002178833819925785, 0.0901869460940361, 0.0099167600274086, 0.0035817474126815796, -0.03892616182565689, -0.011303404346108437, -0.003952186554670334, 0.00562667241320014, -0.022746974602341652, 0.008870518766343594, -0.00248920195735991, -0.02054436318576336, 0.0367235504090786, 0.0101920859888196, -0.014917690306901932, -0.03984725475311279, -0.026971984654664993, -0.00722857192158699, -0.01354606356471777, -0.00013672462955582887, 0.021805858239531517, 0.01087289396673441, -0.026451367884874344, 0.002108750632032752, -0.0009573853458277881, 0.006237396504729986, -0.029915476217865944, -0.0004918332560919225, 0.020143887028098106, 0.04321124404668808, 0.015598497353494167, 0.023127425462007523, 0.007543946150690317, 0.036383144557476044, -0.0034741198178380728, 0.05246221274137497, -0.010702691972255707, -0.002885922323912382, 0.03520174324512482, -0.019843531772494316, -0.01877226121723652, -0.031176971271634102, -0.027652792632579803, -0.006087218411266804, 0.02490953914821148, 0.03107685223221779, -0.020604433491826057, -0.03283894062042236, -0.0318177305161953, -0.006883162539452314, 0.0030736448243260384, -0.03930661082267761, -0.07244591414928436, 0.026591533794999123, 0.020644482225179672, 0.04269062355160713, -0.004980906844139099, 0.05110059678554535, 0.027572697028517723, -0.021946024149656296, 0.026391295716166496, -0.007403779774904251, -0.011944164521992207, 0.045894425362348557, -0.019443057477474213, 0.015488366596400738, 0.01554843783378601, 0.06579802930355072, -0.017230432480573654, -0.036162883043289185, -0.006878156680613756, 0.006107242312282324, -0.20472277700901031, 0.022746974602341652, 0.0010894169099628925, -0.003721913555637002, 0.005611654836684465, 0.01584879495203495, -0.014557262882590294, 0.03101678192615509, -0.0228070467710495, -0.0024328851141035557, -0.033299487084150314, -0.04164939001202583, -0.056947533041238785, -0.015588485635817051, 0.00298103503882885, 0.009331065230071545, -0.016079068183898926, 0.0022539228666573763, 0.006833103019744158, -0.03141725808382034, -0.008304848335683346, 0.0018546994542703032, 0.04229015111923218, -0.03418053314089775, -0.037904951721429825, -0.011954176239669323, 0.03115694783627987, 0.009871706366539001, -0.022406570613384247, 0.024268779903650284, -0.011984211392700672, 0.01721040904521942, -0.010157044976949692, 0.011113178916275501, -0.011803997680544853, 0.012745114043354988, -0.005040978081524372, 0.005766838788986206, 0.015788722783327103, 0.015288129448890686, 0.030736448243260384, 0.030676377937197685, 0.01087289396673441, 0.021805858239531517, 0.007919391617178917, -0.01773102581501007, -0.0066278595477342606, 0.008079580962657928, -0.03614285960793495, -0.043171193450689316, 0.00822475366294384, 0.005196162033826113, 0.03950684890151024, 0.01200423575937748, -0.017110290005803108, 0.033159323036670685, -0.008109617047011852, 0.004450277425348759, -0.03912639990448952, -0.019823508337140083, -0.04541385546326637, -0.019623270258307457, 0.036403167992830276, 0.04593447223305702, 0.0006335638463497162, -0.02362801879644394, -0.00815467070788145, -0.00671796640381217, 0.0020236498676240444, -0.02430882677435875, 0.029174596071243286, -0.011553701013326645, 0.010111991316080093, 0.01986355520784855, -0.011313416063785553, -0.02138536050915718, 0.02062445692718029, -0.0016069056000560522, -0.04893803223967552, -0.12999415397644043, -0.05486506223678589, 0.017040207982063293, 0.005441452842205763, 0.04409228637814522, -0.016129126772284508, -0.04050803557038307, -0.05090036243200302, 0.007373744156211615, 0.015107915736734867, 0.2684783637523651, 0.029074478894472122, 0.014507203362882137, 0.03351974859833717, 0.06403593719005585, -0.0013578602811321616, -0.014377049170434475, -0.002570548327639699, -0.0012589929392561316, -0.012044282630085945, 0.021865930408239365, 0.006377562880516052, 0.02258678525686264, -0.023427782580256462, 0.016219234094023705, 0.02468927763402462, -0.02422873117029667, 0.004300099331885576, 0.06067194789648056, 0.012955362908542156, 0.016870005056262016, -0.001435452257283032, 0.0376446396112442, 0.020604433491826057, -0.010973012074828148, -0.02498963475227356, 0.010712703689932823, 0.027052080258727074, 0.013606134802103043, 0.005151108372956514, 0.001793376635760069, -0.015788722783327103, -0.0007483874796889722, 0.0009598882752470672, -0.0022589287254959345, 0.004154927097260952, 0.02452908828854561, -0.017070243135094643, -0.005957064218819141, -0.0301958080381155, -0.03656335920095444, -0.03802509233355522, 0.009010685607790947, 0.021946024149656296, 0.019663317129015923, -0.03416050970554352, -0.007098417729139328, -0.06607835739850998, -0.011493629775941372, -0.04473304748535156, 0.0005860074306838214, 0.00017051470058504492, -0.03558219596743584, 0.02709212712943554, -0.002210120903328061, -0.012044282630085945, -0.01760087162256241, -0.03958694636821747, -0.04841741546988487, 0.028794145211577415, 0.037524498999118805, 0.02220633439719677, -0.04032782465219498, 0.04014761000871658, -0.00013781969028059393, -0.0016769886715337634, -0.013756313361227512, -0.02867400273680687, 0.026851842179894447, 0.029975546523928642, -0.009921765886247158, -0.0029610113706439734, 0.004552898928523064, 0.013846419751644135, -0.0016356897540390491, -0.024969611316919327, -0.014166799373924732, 0.03151737526059151, 0.004230016376823187, 0.050179507583379745, 0.017200397327542305, -0.03147732838988304, -0.0292146448045969, -0.014987773261964321, 0.0029509994201362133, -0.009981837123632431, -0.06007123738527298, 0.05602644011378288, -0.033539772033691406, -0.04225010424852371, 0.0013616146752610803, -0.014256906695663929, -0.010822834447026253, 0.022626832127571106, -0.04489323869347572, -0.034060392528772354, -0.004280075430870056, 0.016839969903230667, 0.0037844879552721977, 0.00348162860609591, -0.047976892441511154, -0.013906490989029408, -0.0032063021790236235, 0.02054436318576336, 0.04281076788902283, -0.04144915193319321, 0.0016031510895118117, -0.0292747151106596, -9.260982187697664e-05, 0.0034140485804528, 0.031637515872716904, -0.028934311121702194, -0.028774121776223183, 0.014306966215372086, 0.023988446220755577, 0.01749074086546898, 0.0016744857421144843, 0.02468927763402462, -0.009496261365711689, 0.03508160263299942, 0.029034430161118507, 0.004783172160387039, -0.014276930131018162, 0.04525366425514221, -0.03133716061711311, -0.03468112647533417, -0.0237882100045681, 0.02424875646829605, -0.01012200303375721, 0.01080281101167202, -0.0292146448045969, -0.0213052649050951, 0.02400847151875496, 0.044813141226768494, 0.06551769375801086, -0.012765137478709221, 0.06727978587150574, -0.000845377508085221, -0.018431857228279114, 0.027432531118392944, -0.0015743669355288148, -0.02583063207566738, -0.037604592740535736, 0.005907004699110985, 0.010892917402088642, 0.009080768562853336, -0.027532650157809258, -0.0005381381488405168, 0.044452715665102005, 0.06968263536691666, -0.011133202351629734, -0.0163093414157629, 0.003138722153380513, -0.03185777738690376, 0.009861694648861885, -0.007944420911371708, -0.00820973515510559, -0.0016957609914243221, 0.029034430161118507, -0.0405881330370903, -0.004432756453752518, 0.025249943137168884, 0.037364307790994644, 0.05262240394949913, 0.03914642333984375, 0.0048507521860301495, 0.028954336419701576, -0.02356794849038124, -0.0021012418437749147, -0.05066007748246193, 0.004933350253850222, -0.03167756646871567, -0.054905109107494354, 0.018341749906539917, -0.020274043083190918, -0.03115694783627987, -0.02048429101705551, -0.014757500030100346, -0.01347598060965538, -0.014767511747777462, 0.02114507555961609, -0.0021900972351431847, 0.00978159997612238, -0.01789121702313423, -0.024068541824817657, 0.03303917869925499, 0.032558608800172806, -0.019102653488516808, 0.046254850924015045, -0.01991361565887928, -0.018672142177820206, 0.10516471415758133, 0.04449276253581047, -0.019623270258307457, 0.02619105949997902, 0.008174694143235683, 0.016109103336930275, 0.022947212681174278, 0.0012452267110347748, -0.010116997174918652, 0.007283637300133705, -0.04517357051372528, 0.0018534478731453419, 0.02212623879313469, -0.009996854700148106, 0.015177998691797256, -0.0301958080381155, 0.029294738546013832, -0.023427782580256462, 0.024929562583565712, 0.010452395305037498, -0.019713377580046654, -0.0011932901106774807, -0.014897666871547699, -0.01562853343784809, 0.0024729324504733086, 0.05029964819550514, 0.08562153577804565, -0.00033445912413299084, -0.06215370446443558, -0.03301915526390076, 0.009486249648034573, -0.023307640105485916, -0.010262169875204563, 0.05478496849536896, 0.043091099709272385, 0.017590859904885292, -0.02454911172389984, 0.056266725063323975, -0.006192343309521675, -0.003546705935150385, -0.0017883707769215107, 0.03297910839319229, -0.03720412030816078, 0.04689561203122139, -0.03876597061753273, 0.0083999615162611, 0.03816526010632515, 0.019302889704704285, 0.006732984445989132, 0.03746442869305611, -0.03265872970223427, 0.02551025152206421, 0.05158116668462753, -0.0027107144705951214, -0.011383499018847942, -0.014176812022924423, -0.05526553839445114, -0.024789396673440933, 0.04817713052034378, -0.009711516089737415, 0.008064563386142254, -0.005546577274799347, -0.007839296013116837, -0.03347970172762871, -0.02070455253124237, 0.01652960106730461, -0.02400847151875496, -0.005326316226273775, 0.04489323869347572, 0.045053426176309586, 0.010622597299516201, -0.0248294435441494, -0.01776106283068657, -0.04421243071556091, -0.020764624699950218, 0.0247693732380867, -0.022406570613384247, -0.028994383290410042, -0.05802881345152855, -0.005997111555188894, -0.006953245494514704, -0.02236652374267578, -0.022146262228488922, 0.037684690207242966, 0.024969611316919327, -0.0016682283021509647, 0.020884767174720764, 0.0071284533478319645, 0.03882604092359543, -0.009421172551810741, -0.002079966478049755, -0.016809934750199318, 0.021625645458698273, -0.029234668239951134, 0.049578793346881866, 0.032418444752693176, 0.03153739869594574, -0.014767511747777462, -0.03930661082267761, 0.00838994886726141, -0.019593235105276108, -0.044132333248853683, -0.0237882100045681, -0.024749349802732468, 0.020233994349837303, 0.007704135961830616, -0.0015380739932879806, -0.04833732172846794, 0.025610370561480522, -0.0026556493248790503, 0.02364804409444332, -0.0377647839486599, -0.013736288994550705, 0.027913101017475128, 0.027132175862789154, 0.017230432480573654, -0.01719038560986519, 0.03554214909672737, 0.010332252830266953, 0.020193947479128838, -0.0407683439552784, 0.007253601681441069, 0.03596264496445656, 0.013325802981853485, -0.035682313144207, 0.07629047334194183, -0.06972268223762512, -0.00248920195735991, 0.014437120407819748, 0.08393953740596771, 0.012805185280740261, 0.009446201846003532, 0.022006096318364143, -0.028413694351911545, 0.015218046493828297, -0.04032782465219498, 0.02234650030732155, -0.003441581269726157, 0.003719410626217723, -0.034060392528772354, -0.01445714384317398, 0.001198295969516039, -0.027452554553747177, 0.010422359220683575, 0.02741250768303871, 0.04733613505959511, -0.008840483613312244, 0.02867400273680687, 0.011994223110377789, 0.01770099066197872, 0.016619708389043808, 0.04725603759288788, -0.0005534688243642449, 0.030095688998699188, -0.017500752583146095, -0.021105026826262474, -0.005731797311455011, 0.024869492277503014, 0.023127425462007523, -0.01738061010837555, 0.017200397327542305, -0.03846561536192894, -0.023908352479338646, 0.035281840711832047, 0.011453581973910332, -0.006152295973151922, 0.004525366239249706, -0.006257420405745506, -0.022526713088154793, -0.01999370940029621, 0.004640502855181694, -0.027612745761871338, -0.003308923915028572, -0.01069268025457859, 0.01986355520784855, 0.018051406368613243, 0.04417238384485245, -0.003489137627184391, 0.00647267559543252, -0.048978082835674286, 0.0292146448045969, 0.027212269604206085, 0.008204729296267033, -0.03806513920426369, 0.050019316375255585, -0.0028884252533316612, 0.007283637300133705, 0.056266725063323975, -0.0222864281386137, -0.033379584550857544, -0.034881364554166794, -0.04717594385147095, -0.02613098733127117, 0.04569418728351593, -0.027192246168851852, -0.0024654236622154713, 0.022406570613384247, 0.044132333248853683, -0.029074478894472122, 0.008995668031275272, -0.02364804409444332, -0.0004148669831920415, 0.012144401669502258, -0.14465153217315674, 0.007523922249674797, 0.014697428792715073, 0.0003726293798536062, -0.003859577002003789, -0.008655264042317867, -0.030996758490800858, 0.02665160596370697, -0.008384943008422852, -0.03223823010921478, -0.03870590031147003, 0.02763276919722557, 0.0035166703164577484, -0.006878156680613756, 0.00010160486272070557, 0.0054564704187214375, -0.021465454250574112, -0.0066879307851195335, -0.020444244146347046, 0.023067355155944824, -0.03171761333942413, 0.026611557230353355, 0.037524498999118805, 0.01749074086546898, 0.001646953052841127, -0.020254017785191536, 0.02687186561524868, 0.0013553572352975607, -0.0048532551154494286, -0.0057368031702935696, -0.003118698252364993, -0.010442383587360382, 0.007243589963763952, 0.022006096318364143, 0.026451367884874344, 0.013836408033967018, 0.009981837123632431, 0.014026633463799953, -0.0022464138455688953, -0.012444757856428623, -0.016139138489961624, 0.005316304508596659, -0.042730674147605896, -0.012544876895844936, -0.003499149577692151, -0.0016294323140755296, -0.007343708537518978, 0.03161749243736267, -0.004675544332712889, 0.009621409699320793, -0.0020974872168153524, -0.0031912843696773052, -0.002207617973908782, 0.028774121776223183, -0.00613727793097496, 0.0086752874776721, -0.0071885245852172375, -0.021805858239531517, -0.018612071871757507, 0.0476965606212616, 0.0008948111208155751, 0.008845489472150803, -0.03233834728598595, -0.003586753271520138, -0.00425003981217742, -0.017170362174510956, -0.05218188092112541, -0.01080281101167202, -0.019032569602131844, -0.010522478260099888, -0.0407683439552784, 0.020664505660533905, -0.02108500339090824, -0.0006701697129756212, 0.014126752503216267, -0.021645668894052505, 0.027232293039560318, -0.016629720106720924, -0.04024772718548775, 0.018612071871757507, -0.011934151872992516, 0.05021955445408821, -0.025870678946375847, 0.03281891718506813, -0.011513653211295605, 0.020584410056471825, -0.010292205028235912, 0.04389204829931259, -0.04697570577263832, -0.015107915736734867, -0.029334787279367447, -0.03259865567088127, 0.015718640759587288, -0.010932965204119682, 0.039626993238925934, 0.0023390238638967276, -0.0446930006146431, -0.030295927077531815, -0.003196290461346507, -0.03221820667386055, -0.03756454586982727, 0.015818757936358452, -0.0008572665974497795, 0.02266687899827957, 0.003198793390765786, -0.012775149196386337, 0.03950684890151024, 0.018762249499559402, 0.014266918413341045, 0.01611911505460739, 0.029675191268324852, -0.03608278930187225, -0.014697428792715073, 0.01798132248222828, -0.02559034712612629, -0.0016457015881314874, 0.017340563237667084, 0.0001739562867442146, 0.02949497662484646, -0.01185405720025301, -0.022406570613384247, 0.029855404049158096, -0.010642620734870434, -0.0396670401096344, 0.003123704344034195, -0.019873566925525665, -0.016729839146137238, -0.0008322368958033621, 0.03522176668047905, -0.004097358789294958, 0.019933639094233513, -0.011884093284606934, 0.011123190633952618, 0.00782928429543972, 0.04176953434944153, -0.03426062688231468, -0.02234650030732155, 0.04333138465881348, -0.02949497662484646, -0.012154413387179375, -0.012634983286261559, -0.013886467553675175, 0.02430882677435875, -0.00893559679389, 0.014507203362882137, -0.005331322085112333, 0.054384492337703705, 0.03357982262969017, -0.061552993953228, -0.006332509685307741, 0.007238584104925394, 0.049338508397340775, -0.010973012074828148, 0.007799248676747084, -0.03087661601603031, 0.033840131014585495, -0.03674357384443283, 0.01294535119086504, 0.06579802930355072, 0.00429008761420846, 0.01806141808629036, 0.0027132174000144005, 0.013325802981853485, 0.006732984445989132, -0.0011870326707139611, -0.0017070242902264, -0.016709815710783005, -0.020304078236222267, -0.030656354501843452, -0.04108872637152672, 0.0015931392554193735, 0.025029681622982025, 0.007649070583283901, -0.015578473918139935, -0.01562853343784809, -0.022546736523509026, 0.0257505364716053, -0.03576241061091423, 0.060792092233896255, 0.0027782947290688753, 0.018752237781882286, 0.022746974602341652, -0.002427879022434354, 0.01961325854063034, -0.014437120407819748, 0.03646324202418327, -0.03634309768676758, 0.03147732838988304, -0.016900040209293365, 0.05486506223678589, 0.015758687630295753, 0.0040022460743784904, -0.013536051847040653, 0.020584410056471825, 0.024669254198670387, 0.019463080912828445, 0.019002534449100494, -0.0052312035113573074, 0.027652792632579803, -0.012795173563063145, -0.0335998460650444, -0.023607995361089706, 0.003136219223961234, -0.039546895772218704, -0.026911914348602295, 0.01351602841168642, -0.0335998460650444, 0.008955620229244232, -0.028393670916557312, 0.0009811634663492441, -0.00984667707234621, -0.006252414546906948, 0.0046254852786660194, -0.026971984654664993, -0.00011818702478194609, -0.013335814699530602, 0.004109873902052641, -0.004450277425348759, -0.005866957362741232, -0.025930751115083694, 0.0016482045175507665, -0.02054436318576336, -0.02747257798910141, -0.04885793849825859, -0.017590859904885292, 0.004387703258544207, -0.0018622083589434624, 0.0015305650886148214, 0.006507717072963715, 5.172149030840956e-06, 0.01223450805991888, -0.0183617752045393, -0.024148637428879738, 0.009105797857046127, 0.019242819398641586, -0.011613772250711918, 0.015918876975774765, 0.02304733172059059, 0.0158788301050663, 0.00444777449592948, 0.004400217905640602, -0.0012226999970152974, -0.03848563879728317, 0.04094855859875679]]\n",
      "✓ Embedding 模型初始化完成\n",
      "  模型: text-embedding-v3\n",
      "  维度: 1024\n",
      "  API 端点: https://dashscope.aliyuncs.com/compatible-mode/v1\n"
     ]
    }
   ],
   "source": [
    "# 初始化 embedding 模型\n",
    "from langchain_openai import OpenAIEmbeddings\n",
    "from langchain_community.embeddings import DashScopeEmbeddings\n",
    "\n",
    "EMBEDDING_URL = \"https://dashscope.aliyuncs.com/compatible-mode/v1\"\n",
    "EMBEDDING_KEY = \"sk-8d7ac86d58cd49c8966a0aeea75f1c28\"\n",
    "EMBEDDING_MODEL = \"text-embedding-v3\"\n",
    "\n",
    "embeddings = DashScopeEmbeddings(\n",
    "    model=\"text-embedding-v3\", dashscope_api_key=EMBEDDING_KEY\n",
    ")\n",
    "\n",
    "text = \"This is a test document.\"\n",
    "\n",
    "query_result = embeddings.embed_query(text)\n",
    "print(query_result)\n",
    "\n",
    "doc_results = embeddings.embed_documents([\"foo\"])\n",
    "print(doc_results)\n",
    "\n",
    "\n",
    "print(\"✓ Embedding 模型初始化完成\")\n",
    "print(f\"  模型: {EMBEDDING_MODEL}\")\n",
    "print(f\"  维度: 1024\")\n",
    "print(f\"  API 端点: {EMBEDDING_URL}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "vectorstore",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✅ 向量存储创建完成\n"
     ]
    }
   ],
   "source": [
    "# 创建向量存储 - 修复变量名错误\n",
    "from langchain_postgres import PGVectorStore\n",
    "\n",
    "try:\n",
    "    store = await PGVectorStore.create(\n",
    "        engine=pg_engine,\n",
    "        table_name=TABLE_NAME,\n",
    "        embedding_service=embeddings,  # 修复: 使用正确的变量名 embeddings\n",
    "    )\n",
    "    print(\"✅ 向量存储创建完成\")\n",
    "except Exception as e:\n",
    "    print(f\"❌ 创建向量存储失败: {e}\")\n",
    "    print(f\"错误类型: {type(e).__name__}\")\n",
    "    import traceback\n",
    "    traceback.print_exc()\n",
    "    raise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "3d02d2b0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "测试文本: 这是一个简单的测试文本\n",
      "文本类型: <class 'str'>\n",
      "文本长度: 11\n",
      "开始调用 embedding API...\n",
      "✅ Embedding 测试成功，维度: 1024\n",
      "前5个向量值: [-0.10154081881046295, 0.06474567204713821, -0.06853622198104858, -0.026935884729027748, -0.014425151981413364]\n",
      "✅ Embedding 测试成功，维度: 1024\n",
      "前5个向量值: [-0.10154081881046295, 0.06474567204713821, -0.06853622198104858, -0.026935884729027748, -0.014425151981413364]\n"
     ]
    }
   ],
   "source": [
    "# 简单 embedding 测试 - 修复版本\n",
    "test_text = \"这是一个简单的测试文本\"\n",
    "print(f\"测试文本: {test_text}\")\n",
    "print(f\"文本类型: {type(test_text)}\")\n",
    "print(f\"文本长度: {len(test_text)}\")\n",
    "\n",
    "try:\n",
    "    # 确保传递正确的字符串类型\n",
    "    if not isinstance(test_text, str):\n",
    "        test_text = str(test_text)\n",
    "    \n",
    "    print(\"开始调用 embedding API...\")\n",
    "    embedding_result = await embeddings.aembed_query(test_text)\n",
    "    print(f\"✅ Embedding 测试成功，维度: {len(embedding_result)}\")\n",
    "    print(f\"前5个向量值: {embedding_result[:5]}\")\n",
    "    \n",
    "except Exception as e:\n",
    "    print(f\"❌ Embedding 测试失败: {e}\")\n",
    "    print(f\"错误类型: {type(e).__name__}\")\n",
    "    import traceback\n",
    "    traceback.print_exc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "10ba934f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "测试文本: 这是一个简单的测试文本\n",
      "文本类型: <class 'str'>\n",
      "文本长度: 11\n",
      "开始调用 embedding API...\n",
      "✅ Embedding 测试成功，维度: 1024\n",
      "前5个向量值: [-0.10154081881046295, 0.06474567204713821, -0.06853622198104858, -0.026935884729027748, -0.014425151981413364]\n",
      "✅ Embedding 测试成功，维度: 1024\n",
      "前5个向量值: [-0.10154081881046295, 0.06474567204713821, -0.06853622198104858, -0.026935884729027748, -0.014425151981413364]\n"
     ]
    }
   ],
   "source": [
    "# 简单 embedding 测试 - 修复版本\n",
    "test_text = \"这是一个简单的测试文本\"\n",
    "print(f\"测试文本: {test_text}\")\n",
    "print(f\"文本类型: {type(test_text)}\")\n",
    "print(f\"文本长度: {len(test_text)}\")\n",
    "\n",
    "try:\n",
    "    # 确保传递正确的字符串类型\n",
    "    if not isinstance(test_text, str):\n",
    "        test_text = str(test_text)\n",
    "    \n",
    "    print(\"开始调用 embedding API...\")\n",
    "    embedding_result = await embeddings.aembed_query(test_text)\n",
    "    print(f\"✅ Embedding 测试成功，维度: {len(embedding_result)}\")\n",
    "    print(f\"前5个向量值: {embedding_result[:5]}\")\n",
    "    \n",
    "except Exception as e:\n",
    "    print(f\"❌ Embedding 测试失败: {e}\")\n",
    "    print(f\"错误类型: {type(e).__name__}\")\n",
    "    import traceback\n",
    "    traceback.print_exc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "create_documents",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "内容 1:\n",
      "  类型: <class 'str'>\n",
      "  长度: 51\n",
      "  预览: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念...\n",
      "  ✓ 验证通过\n",
      "\n",
      "内容 2:\n",
      "  类型: <class 'str'>\n",
      "  长度: 51\n",
      "  预览: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用...\n",
      "  ✓ 验证通过\n",
      "\n",
      "内容 3:\n",
      "  类型: <class 'str'>\n",
      "  长度: 47\n",
      "  预览: 这是第三个测试文档的内容。它介绍了自然语言处理的发展历程，从早期的规则方法到现代的大语言模型。...\n",
      "  ✓ 验证通过\n",
      "\n",
      "最终验证文档格式...\n",
      "文档 1:\n",
      "  ID: f40a01a1-bcbc-48d4-9b86-d8cead91a6c8\n",
      "  内容类型: <class 'str'>\n",
      "  内容长度: 51\n",
      "  内容预览: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念...\n",
      "  元数据: {'source': 'test_doc_1', 'category': 'AI', 'length': 51}\n",
      "  ✅ 文档 1 格式验证通过\n",
      "\n",
      "文档 2:\n",
      "  ID: 7a1753b2-2851-4468-909a-f862d953874a\n",
      "  内容类型: <class 'str'>\n",
      "  内容长度: 51\n",
      "  内容预览: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用...\n",
      "  元数据: {'source': 'test_doc_2', 'category': 'ML', 'length': 51}\n",
      "  ✅ 文档 2 格式验证通过\n",
      "\n",
      "文档 3:\n",
      "  ID: 733cc75a-8cf9-40ac-863e-2821396264f2\n",
      "  内容类型: <class 'str'>\n",
      "  内容长度: 47\n",
      "  内容预览: 这是第三个测试文档的内容。它介绍了自然语言处理的发展历程，从早期的规则方法到现代的大语言模型。...\n",
      "  元数据: {'source': 'test_doc_3', 'category': 'NLP', 'length': 47}\n",
      "  ✅ 文档 3 格式验证通过\n",
      "\n",
      "✅ 所有 3 个文档格式验证通过\n"
     ]
    }
   ],
   "source": [
    "# 创建文档 - 确保格式严格正确\n",
    "import uuid\n",
    "from langchain_core.documents import Document\n",
    "\n",
    "# 预定义内容，确保都是字符串类型\n",
    "content_1 = \"这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念。\"\n",
    "content_2 = \"这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用。\"\n",
    "content_3 = \"这是第三个测试文档的内容。它介绍了自然语言处理的发展历程，从早期的规则方法到现代的大语言模型。\"\n",
    "\n",
    "# 验证内容\n",
    "contents = [content_1, content_2, content_3]\n",
    "for i, content in enumerate(contents, 1):\n",
    "    print(f\"内容 {i}:\")\n",
    "    print(f\"  类型: {type(content)}\")\n",
    "    print(f\"  长度: {len(content)}\")\n",
    "    print(f\"  预览: {content[:50]}...\")\n",
    "    assert isinstance(content, str), f\"内容 {i} 不是字符串类型\"\n",
    "    assert len(content.strip()) > 0, f\"内容 {i} 为空\"\n",
    "    print(f\"  ✓ 验证通过\")\n",
    "    print()\n",
    "\n",
    "# 创建文档对象\n",
    "docs = [\n",
    "    Document(\n",
    "        id=str(uuid.uuid4()),\n",
    "        page_content=content_1,\n",
    "        metadata={\"source\": \"test_doc_1\", \"category\": \"AI\", \"length\": len(content_1)}\n",
    "    ),\n",
    "    Document(\n",
    "        id=str(uuid.uuid4()),\n",
    "        page_content=content_2,\n",
    "        metadata={\"source\": \"test_doc_2\", \"category\": \"ML\", \"length\": len(content_2)}\n",
    "    ),\n",
    "    Document(\n",
    "        id=str(uuid.uuid4()),\n",
    "        page_content=content_3,\n",
    "        metadata={\"source\": \"test_doc_3\", \"category\": \"NLP\", \"length\": len(content_3)}\n",
    "    ),\n",
    "]\n",
    "\n",
    "# 最终验证文档格式\n",
    "print(\"最终验证文档格式...\")\n",
    "for i, doc in enumerate(docs, 1):\n",
    "    print(f\"文档 {i}:\")\n",
    "    print(f\"  ID: {doc.id}\")\n",
    "    print(f\"  内容类型: {type(doc.page_content)}\")\n",
    "    print(f\"  内容长度: {len(doc.page_content)}\")\n",
    "    print(f\"  内容预览: {doc.page_content[:50]}...\")\n",
    "    print(f\"  元数据: {doc.metadata}\")\n",
    "    \n",
    "    # 严格验证\n",
    "    if not isinstance(doc.page_content, str):\n",
    "        raise TypeError(f\"文档 {i} 的 page_content 必须是字符串类型，当前类型: {type(doc.page_content)}\")\n",
    "    if len(doc.page_content.strip()) == 0:\n",
    "        raise ValueError(f\"文档 {i} 的 page_content 不能为空\")\n",
    "    \n",
    "    print(f\"  ✅ 文档 {i} 格式验证通过\")\n",
    "    print()\n",
    "\n",
    "print(f\"✅ 所有 {len(docs)} 个文档格式验证通过\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "add_documents",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "开始添加文档到向量存储...\n",
      "✓ 文档 1 准备就绪\n",
      "✓ 文档 2 准备就绪\n",
      "✓ 文档 3 准备就绪\n",
      "\n",
      "正在调用 aadd_documents...\n",
      "✅ 成功添加 3 个文档\n",
      "文档ID: ['f40a01a1-bcbc-48d4-9b86-d8cead91a6c8', '7a1753b2-2851-4468-909a-f862d953874a', '733cc75a-8cf9-40ac-863e-2821396264f2']\n",
      "✅ 成功添加 3 个文档\n",
      "文档ID: ['f40a01a1-bcbc-48d4-9b86-d8cead91a6c8', '7a1753b2-2851-4468-909a-f862d953874a', '733cc75a-8cf9-40ac-863e-2821396264f2']\n"
     ]
    }
   ],
   "source": [
    "# 添加文档到向量存储 - 完全安全版本\n",
    "try:\n",
    "    print(\"开始添加文档到向量存储...\")\n",
    "    \n",
    "    # 添加前最后一次验证\n",
    "    for i, doc in enumerate(docs, 1):\n",
    "        if not isinstance(doc.page_content, str):\n",
    "            print(f\"⚠️ 警告: 文档 {i} 内容不是字符串，正在转换...\")\n",
    "            doc.page_content = str(doc.page_content)\n",
    "        if not doc.page_content.strip():\n",
    "            print(f\"⚠️ 警告: 文档 {i} 内容为空，设置默认内容...\")\n",
    "            doc.page_content = f\"默认内容 {i}\"\n",
    "        print(f\"✓ 文档 {i} 准备就绪\")\n",
    "    \n",
    "    print(\"\\n正在调用 aadd_documents...\")\n",
    "    document_ids = await store.aadd_documents(docs)\n",
    "    print(f\"✅ 成功添加 {len(document_ids)} 个文档\")\n",
    "    print(f\"文档ID: {document_ids}\")\n",
    "    \n",
    "except Exception as e:\n",
    "    print(f\"❌ 添加文档失败: {e}\")\n",
    "    print(f\"错误类型: {type(e).__name__}\")\n",
    "    \n",
    "    # 详细错误分析\n",
    "    if \"contents is neither str nor list of str\" in str(e):\n",
    "        print(\"\\n🔍 错误分析: embedding API 收到了非字符串内容\")\n",
    "        print(\"正在检查文档内容...\")\n",
    "        for i, doc in enumerate(docs, 1):\n",
    "            print(f\"文档 {i}: 类型={type(doc.page_content)}, 值={repr(doc.page_content[:50])}\")\n",
    "    \n",
    "    import traceback\n",
    "    traceback.print_exc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "test_search",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "查询: 什么是机器学习？\n",
      "查询类型: <class 'str'>\n",
      "\n",
      "✅ 找到 2 个相关文档:\n",
      "\n",
      "结果 1:\n",
      "内容: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用。\n",
      "元数据: {'source': 'test_doc_2', 'category': 'ML', 'length': 51}\n",
      "\n",
      "结果 2:\n",
      "内容: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念。\n",
      "元数据: {'source': 'test_doc_1', 'category': 'AI', 'length': 51}\n",
      "\n",
      "✅ 找到 2 个相关文档:\n",
      "\n",
      "结果 1:\n",
      "内容: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用。\n",
      "元数据: {'source': 'test_doc_2', 'category': 'ML', 'length': 51}\n",
      "\n",
      "结果 2:\n",
      "内容: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念。\n",
      "元数据: {'source': 'test_doc_1', 'category': 'AI', 'length': 51}\n"
     ]
    }
   ],
   "source": [
    "# 测试相似性搜索\n",
    "if 'document_ids' in locals() and document_ids:\n",
    "    query = \"什么是机器学习？\"\n",
    "    try:\n",
    "        print(f\"查询: {query}\")\n",
    "        print(f\"查询类型: {type(query)}\")\n",
    "        \n",
    "        results = await store.asimilarity_search(query, k=2)\n",
    "        \n",
    "        print(f\"\\n✅ 找到 {len(results)} 个相关文档:\")\n",
    "        for i, result in enumerate(results, 1):\n",
    "            print(f\"\\n结果 {i}:\")\n",
    "            print(f\"内容: {result.page_content}\")\n",
    "            print(f\"元数据: {result.metadata}\")\n",
    "            \n",
    "    except Exception as e:\n",
    "        print(f\"❌ 搜索失败: {e}\")\n",
    "        import traceback\n",
    "        traceback.print_exc()\n",
    "else:\n",
    "    print(\"⚠️ 跳过搜索测试，因为文档添加失败\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "test_search_with_score",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "查询: 自然语言处理的发展\n",
      "\n",
      "✅ 找到 3 个相关文档（带相似度分数）:\n",
      "\n",
      "结果 1 (相似度: 0.2059):\n",
      "内容: 这是第三个测试文档的内容。它介绍了自然语言处理的发展历程，从早期的规则方法到现代的大语言模型。\n",
      "元数据: {'source': 'test_doc_3', 'category': 'NLP', 'length': 47}\n",
      "\n",
      "结果 2 (相似度: 0.4753):\n",
      "内容: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用。\n",
      "元数据: {'source': 'test_doc_2', 'category': 'ML', 'length': 51}\n",
      "\n",
      "结果 3 (相似度: 0.5568):\n",
      "内容: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念。\n",
      "元数据: {'source': 'test_doc_1', 'category': 'AI', 'length': 51}\n",
      "\n",
      "✅ 找到 3 个相关文档（带相似度分数）:\n",
      "\n",
      "结果 1 (相似度: 0.2059):\n",
      "内容: 这是第三个测试文档的内容。它介绍了自然语言处理的发展历程，从早期的规则方法到现代的大语言模型。\n",
      "元数据: {'source': 'test_doc_3', 'category': 'NLP', 'length': 47}\n",
      "\n",
      "结果 2 (相似度: 0.4753):\n",
      "内容: 这是第二个测试文档的内容。它讨论了机器学习的应用场景，包括图像识别、自然语言处理、推荐系统等实际应用。\n",
      "元数据: {'source': 'test_doc_2', 'category': 'ML', 'length': 51}\n",
      "\n",
      "结果 3 (相似度: 0.5568):\n",
      "内容: 这是第一个测试文档的内容。它包含了一些关于AI技术的信息，包括机器学习、深度学习和神经网络等相关概念。\n",
      "元数据: {'source': 'test_doc_1', 'category': 'AI', 'length': 51}\n"
     ]
    }
   ],
   "source": [
    "# 测试带分数的相似性搜索\n",
    "if 'document_ids' in locals() and document_ids:\n",
    "    query = \"自然语言处理的发展\"\n",
    "    try:\n",
    "        print(f\"查询: {query}\")\n",
    "        results = await store.asimilarity_search_with_score(query, k=3)\n",
    "        \n",
    "        print(f\"\\n✅ 找到 {len(results)} 个相关文档（带相似度分数）:\")\n",
    "        for i, (doc, score) in enumerate(results, 1):\n",
    "            print(f\"\\n结果 {i} (相似度: {score:.4f}):\")\n",
    "            print(f\"内容: {doc.page_content}\")\n",
    "            print(f\"元数据: {doc.metadata}\")\n",
    "            \n",
    "    except Exception as e:\n",
    "        print(f\"❌ 带分数搜索失败: {e}\")\n",
    "        import traceback\n",
    "        traceback.print_exc()\n",
    "else:\n",
    "    print(\"⚠️ 跳过带分数搜索测试，因为文档添加失败\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
